当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript modelAssertions.ok方法代码示例

本文整理汇总了TypeScript中klay-core.modelAssertions.ok方法的典型用法代码示例。如果您正苦于以下问题:TypeScript modelAssertions.ok方法的具体用法?TypeScript modelAssertions.ok怎么用?TypeScript modelAssertions.ok使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在klay-core.modelAssertions的用法示例。


在下文中一共展示了modelAssertions.ok方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: addModel

  public addModel(kilnModel: IKilnModelInput): IKiln {
    modelAssertions.typeof(kilnModel.name, 'string', 'name')
    modelAssertions.ok(kilnModel.model.isKlayModel, 'model must be a klay model')
    modelAssertions.ok(!this._models.has(kilnModel.name), 'model with same name already exists')

    const meta = {plural: `${kilnModel.name}s`, ...kilnModel.meta}
    this._models.set(kilnModel.name, {...kilnModel, meta, extensions: new Map()})
    return this
  }
开发者ID:patrickhulce,项目名称:klay,代码行数:9,代码来源:kiln.ts

示例2:

 private _getExtensionInputOrThrow<TResult, TOptions>(
   modelName: string,
   extensionName: string,
 ): IKilnExtensionInput<TResult, TOptions> {
   const extension = this._getExtensionInput<TResult, TOptions>(modelName, extensionName)
   modelAssertions.ok(extension, `unable to find extension "${extensionName}"`)
   return extension!
 }
开发者ID:patrickhulce,项目名称:klay,代码行数:8,代码来源:kiln.ts

示例3: index

  public index(properties: IIndexPropertyInput[]): IDatabaseOptions {
    assertions.typeof(properties, 'array', 'index')
    assertions.ok(properties.length, 'must specify at least 1 property for index')
    properties.forEach((item, i) => {
      properties[i] = DatabaseOptions._determineIndex(item, i)
    })

    this.spec.index.push(properties as IIndexProperty[])
    return this
  }
开发者ID:patrickhulce,项目名称:klay,代码行数:10,代码来源:options.ts

示例4: _determineSupplyWith

  private static _determineSupplyWith(
    supplyWith: ISupplyWithFunction | SupplyWithPreset,
  ): ISupplyWithFunction | SupplyWithPreset {
    if (supplyWith === SupplyWithPreset.AutoIncrement || typeof supplyWith === 'function') {
      return supplyWith
    }

    const supplyWithFunc = supplyWithPresets[supplyWith]
    assertions.ok(supplyWithFunc, 'invalid automanage supplyWith')
    return supplyWithFunc
  }
开发者ID:patrickhulce,项目名称:klay,代码行数:11,代码来源:options.ts

示例5: findModel

export function findModel(model: IModel, pathToModel: string[]): IModel {
  let target = model

  const parts = pathToModel.slice()
  while (parts.length) {
    modelAssertions.typeof(target.spec.children, 'array', 'children')
    const nextPath = parts.shift()
    const found = (target.spec.children as IModelChild[]).find(child => child.path === nextPath)
    modelAssertions.ok(found, `could not find model child ${nextPath}`)
    target = found!.model
  }

  return target
}
开发者ID:patrickhulce,项目名称:klay,代码行数:14,代码来源:helpers.ts

示例6: constrain

  public constrain(input: IConstraintInput): IDatabaseOptions {
    assertions.typeof(input, 'object', 'constrain')
    input.properties = input.properties || [[]]
    input.meta = input.meta || {}

    assertions.typeof(input.properties, 'array', 'constrain.propertyPaths')
    assertions.ok(input.properties.length, 'must specify at least 1 property for constrain')
    assertions.oneOf(input.type, values(ConstraintType), 'constrain.type')
    assertions.typeof(input.meta, 'object')

    const constrain = input as IConstraint
    constrain.name = DatabaseOptions.computeConstraintName(constrain)
    constrain.meta = DatabaseOptions.computeMetaProperties(constrain)
    this.spec.constrain.push(constrain)
    return this
  }
开发者ID:patrickhulce,项目名称:klay,代码行数:16,代码来源:options.ts

示例7: map

  const routes: IRouterRoute[] = map(routerOptions.routes, (typeOrOption, key) => {
    const [method, path] = key.split(' ')
    const routeOptions = typeof typeOrOption === 'string' ? {type: typeOrOption} : typeOrOption
    const route = createRouteOrActionRoute(routeOptions, routerOptions, kilnModel, executor)

    for (const [name, handler] of entries(route.paramHandlers)) {
      const existing = paramHandlers[name] || handler
      modelAssertions.ok(
        isEqual(existing.model.spec, handler.model.spec),
        `incompatible params model for ${name}`,
      )

      paramHandlers[name] = handler
    }

    return {
      path,
      method: method.toLowerCase() as HTTPMethod,
      options: routeOptions,
      kilnModel,
      ...route,
    }
  })
开发者ID:patrickhulce,项目名称:klay,代码行数:23,代码来源:create-router.ts

示例8: _getModelOrThrow

 private _getModelOrThrow(modelName: string): IKilnModel {
   const kilnModel = this._models.get(modelName)
   modelAssertions.ok(kilnModel, `unable to find model "${modelName}"`)
   return kilnModel!
 }
开发者ID:patrickhulce,项目名称:klay,代码行数:5,代码来源:kiln.ts


注:本文中的klay-core.modelAssertions.ok方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。