@gaganref/confect-core 10.3.1-fork.4 → 10.3.1-fork.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/ActionCall.d.ts +18 -0
  2. package/dist/ActionCall.d.ts.map +1 -0
  3. package/dist/ActionCall.js +21 -0
  4. package/dist/ActionCall.js.map +1 -0
  5. package/dist/App.d.ts +14 -3
  6. package/dist/App.d.ts.map +1 -1
  7. package/dist/App.js +6 -3
  8. package/dist/App.js.map +1 -1
  9. package/dist/Auth.d.ts +33 -8
  10. package/dist/Auth.d.ts.map +1 -1
  11. package/dist/Auth.js +15 -1
  12. package/dist/Auth.js.map +1 -1
  13. package/dist/Callback.d.ts +3 -3
  14. package/dist/Callback.d.ts.map +1 -1
  15. package/dist/Callback.js +2 -2
  16. package/dist/Callback.js.map +1 -1
  17. package/dist/Component.d.ts +8 -8
  18. package/dist/Component.d.ts.map +1 -1
  19. package/dist/Component.js +1 -1
  20. package/dist/Component.js.map +1 -1
  21. package/dist/FunctionProvenance.d.ts +2 -2
  22. package/dist/FunctionProvenance.d.ts.map +1 -1
  23. package/dist/FunctionProvenance.js.map +1 -1
  24. package/dist/FunctionSpec.d.ts +329 -5
  25. package/dist/FunctionSpec.d.ts.map +1 -1
  26. package/dist/FunctionSpec.js +53 -3
  27. package/dist/FunctionSpec.js.map +1 -1
  28. package/dist/GenericId.d.ts +2 -2
  29. package/dist/GenericId.d.ts.map +1 -1
  30. package/dist/GenericId.js.map +1 -1
  31. package/dist/GroupPath.d.ts +1 -1
  32. package/dist/GroupPath.d.ts.map +1 -1
  33. package/dist/GroupPath.js.map +1 -1
  34. package/dist/GroupSpec.d.ts +4 -4
  35. package/dist/GroupSpec.d.ts.map +1 -1
  36. package/dist/GroupSpec.js +1 -1
  37. package/dist/GroupSpec.js.map +1 -1
  38. package/dist/Http.d.ts +1 -1
  39. package/dist/Http.d.ts.map +1 -1
  40. package/dist/Http.js.map +1 -1
  41. package/dist/Manifest.d.ts +1 -1
  42. package/dist/Manifest.d.ts.map +1 -1
  43. package/dist/Manifest.js.map +1 -1
  44. package/dist/MiddlewareAttachment.d.ts +1 -1
  45. package/dist/MiddlewareAttachment.d.ts.map +1 -1
  46. package/dist/MiddlewareAttachment.js.map +1 -1
  47. package/dist/MiddlewareSpec.d.ts +3 -3
  48. package/dist/MiddlewareSpec.d.ts.map +1 -1
  49. package/dist/MiddlewareSpec.js.map +1 -1
  50. package/dist/Profile.d.ts +95 -0
  51. package/dist/Profile.d.ts.map +1 -0
  52. package/dist/Profile.js +15 -0
  53. package/dist/Profile.js.map +1 -0
  54. package/dist/Ref.d.ts +8 -7
  55. package/dist/Ref.d.ts.map +1 -1
  56. package/dist/Ref.js +7 -4
  57. package/dist/Ref.js.map +1 -1
  58. package/dist/Refs.d.ts +5 -5
  59. package/dist/Refs.d.ts.map +1 -1
  60. package/dist/Refs.js.map +1 -1
  61. package/dist/SchemaToValidator.d.ts +2 -2
  62. package/dist/SchemaToValidator.d.ts.map +1 -1
  63. package/dist/SchemaToValidator.js +1 -1
  64. package/dist/SchemaToValidator.js.map +1 -1
  65. package/dist/Spec.d.ts +1 -1
  66. package/dist/Spec.d.ts.map +1 -1
  67. package/dist/Spec.js.map +1 -1
  68. package/dist/SystemFields.d.ts +2 -2
  69. package/dist/SystemFields.d.ts.map +1 -1
  70. package/dist/SystemFields.js +1 -1
  71. package/dist/SystemFields.js.map +1 -1
  72. package/dist/Table.d.ts +3 -3
  73. package/dist/Table.d.ts.map +1 -1
  74. package/dist/Table.js.map +1 -1
  75. package/dist/index.d.ts +31 -29
  76. package/dist/index.d.ts.map +1 -1
  77. package/dist/index.js +8 -6
  78. package/package.json +3 -3
  79. package/src/ActionCall.ts +25 -0
  80. package/src/App.ts +20 -4
  81. package/src/Auth.ts +50 -8
  82. package/src/Callback.ts +4 -3
  83. package/src/Component.ts +12 -11
  84. package/src/FunctionProvenance.ts +3 -3
  85. package/src/FunctionSpec.ts +509 -9
  86. package/src/GenericId.ts +2 -2
  87. package/src/GroupPath.ts +1 -1
  88. package/src/GroupSpec.ts +5 -5
  89. package/src/Http.ts +1 -1
  90. package/src/Manifest.ts +1 -1
  91. package/src/MiddlewareAttachment.ts +1 -1
  92. package/src/MiddlewareSpec.ts +4 -4
  93. package/src/Profile.ts +141 -0
  94. package/src/Ref.ts +19 -10
  95. package/src/Refs.ts +5 -5
  96. package/src/SchemaToValidator.ts +3 -3
  97. package/src/Spec.ts +1 -1
  98. package/src/SystemFields.ts +2 -2
  99. package/src/Table.ts +4 -4
  100. package/src/index.ts +31 -29
package/dist/Table.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Table.js","names":["SystemFields.extendWithSystemFields","IdScope.app"],"sources":["../src/Table.ts"],"sourcesContent":["import * as IdScope from \"./IdScope\";\nimport * as Lazy from \"./Lazy\";\nimport * as SystemFields from \"./SystemFields\";\nimport type { TableSchemaToTableValidator } from \"./SchemaToValidator\";\nimport type {\n SystemFields as ConvexSystemFields,\n Expand,\n GenericTableIndexes,\n GenericTableSearchIndexes,\n GenericTableVectorIndexes,\n IndexTiebreakerField,\n SearchIndexConfig,\n VectorIndexConfig,\n} from \"convex/server\";\nimport type { GenericValidator, Validator } from \"convex/values\";\nimport * as Predicate from \"effect/Predicate\";\nimport type * as Schema from \"effect/Schema\";\n\nexport const TypeId = \"~@confect/core/Table\";\nexport type TypeId = typeof TypeId;\n\n// -----------------------------------------------------------------------------\n// Predicates\n// -----------------------------------------------------------------------------\n//\n// Both bound `Table`s and `UnnamedTable` callables share the same `[TypeId]`\n// brand. They disambiguate by whether a `tableName` property is set: bound\n// tables have one, unnamed callables do not.\n//\n// The discriminator is `tableName` (not `name`) so it does not collide with\n// the built-in `Function.prototype.name` that every JS function carries.\n\nexport const isTable = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId) && Predicate.hasProperty(u, \"tableName\");\n\nexport const isUnnamedTable = (u: unknown): u is UnnamedAny =>\n Predicate.hasProperty(u, TypeId) && !Predicate.hasProperty(u, \"tableName\");\n\n// -----------------------------------------------------------------------------\n// Bound Table\n// -----------------------------------------------------------------------------\n//\n// A bound `Table` is the client-safe document schema: `Fields`, `Doc`, and\n// the index metadata records. The Convex deploy `tableDefinition` (which\n// value-imports `convex/server`) is produced separately by\n// `@confect/server/Table.tableDefinition`.\n\nexport interface Table<\n Name_ extends string,\n TableSchema_ extends Schema.Codec<any, any>,\n TableValidator_ extends GenericValidator =\n TableSchemaToTableValidator<TableSchema_>,\n Indexes_ extends GenericTableIndexes = {},\n SearchIndexes_ extends GenericTableSearchIndexes = {},\n VectorIndexes_ extends GenericTableVectorIndexes = {},\n Scope_ extends IdScope.IdScope = IdScope.App,\n> {\n readonly [TypeId]: TypeId;\n readonly tableName: Name_;\n readonly scope: Scope_;\n readonly Fields: TableSchema_;\n readonly Doc: SystemFields.ExtendWithSystemFields<\n Name_,\n TableSchema_,\n Scope_\n >;\n readonly indexes: Indexes_;\n readonly searchIndexes: SearchIndexes_;\n readonly vectorIndexes: VectorIndexes_;\n readonly \"~TableValidator\": TableValidator_;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n readonly tableName: string;\n}\n\nexport type AnyWithProps = Table<\n any,\n Schema.Codec<any, any>,\n GenericValidator,\n GenericTableIndexes,\n GenericTableSearchIndexes,\n GenericTableVectorIndexes,\n IdScope.IdScope\n>;\n\n// -----------------------------------------------------------------------------\n// UnnamedTable (callable)\n// -----------------------------------------------------------------------------\n//\n// `Table.make(lazyFields)` returns an `UnnamedTable`: a callable that\n// produces a fully bound `Table` when invoked with a name. Chaining methods\n// (`.index`, `.searchIndex`, `.vectorIndex`) live here and return new\n// `UnnamedTable`s, accumulating plain index metadata records. The\n// user-supplied `lazyFields` callback is just carried through until first\n// access of `Fields`/`Doc` on a bound table. The codegen pipeline emits a\n// wrapper file per user-authored table that simply invokes the unnamed\n// callable with the filename basename.\n\nexport interface UnnamedTable<\n TableSchema_ extends Schema.Codec<any, any>,\n TableValidator_ extends GenericValidator =\n TableSchemaToTableValidator<TableSchema_>,\n Indexes_ extends GenericTableIndexes = {},\n SearchIndexes_ extends GenericTableSearchIndexes = {},\n VectorIndexes_ extends GenericTableVectorIndexes = {},\n> {\n <\n const Name_ extends string,\n const Scope_ extends IdScope.IdScope = IdScope.App,\n >(\n tableName: Name_,\n scope?: Scope_,\n ): Table<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n >;\n\n readonly [TypeId]: TypeId;\n readonly indexes: Indexes_;\n readonly searchIndexes: SearchIndexes_;\n readonly vectorIndexes: VectorIndexes_;\n readonly \"~TableValidator\": TableValidator_;\n\n index<\n IndexName extends string,\n FirstFieldPath extends ExtractFieldPaths<TableValidator_>,\n RestFieldPaths extends ExtractFieldPaths<TableValidator_>[],\n >(\n name: IndexName,\n fields: [FirstFieldPath, ...RestFieldPaths],\n ): UnnamedTable<\n TableSchema_,\n TableValidator_,\n Expand<\n Indexes_ &\n Record<\n IndexName,\n [FirstFieldPath, ...RestFieldPaths, IndexTiebreakerField]\n >\n >,\n SearchIndexes_,\n VectorIndexes_\n >;\n\n searchIndex<\n IndexName extends string,\n SearchField extends ExtractFieldPaths<TableValidator_>,\n FilterFields extends ExtractFieldPaths<TableValidator_> = never,\n >(\n name: IndexName,\n indexConfig: Expand<SearchIndexConfig<SearchField, FilterFields>>,\n ): UnnamedTable<\n TableSchema_,\n TableValidator_,\n Indexes_,\n Expand<\n SearchIndexes_ &\n Record<\n IndexName,\n {\n searchField: SearchField;\n filterFields: FilterFields;\n }\n >\n >,\n VectorIndexes_\n >;\n\n vectorIndex<\n IndexName extends string,\n VectorField extends ExtractFieldPaths<TableValidator_>,\n FilterFields extends ExtractFieldPaths<TableValidator_> = never,\n >(\n name: IndexName,\n indexConfig: Expand<VectorIndexConfig<VectorField, FilterFields>>,\n ): UnnamedTable<\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n Expand<\n VectorIndexes_ &\n Record<\n IndexName,\n {\n vectorField: VectorField;\n dimensions: number;\n filterFields: FilterFields;\n }\n >\n >\n >;\n}\n\nexport interface UnnamedAny {\n readonly [TypeId]: TypeId;\n}\n\nexport type UnnamedAnyWithProps = UnnamedTable<\n Schema.Codec<any, any>,\n GenericValidator,\n GenericTableIndexes,\n GenericTableSearchIndexes,\n GenericTableVectorIndexes\n>;\n\n// -----------------------------------------------------------------------------\n// Type extractors\n// -----------------------------------------------------------------------------\n\nexport type Name<TableDef extends AnyWithProps> = TableDef[\"tableName\"] &\n string;\n\nexport type TableSchema<TableDef extends AnyWithProps> = TableDef[\"Fields\"];\n\nexport type TableValidator<TableDef extends AnyWithProps> =\n TableDef[\"~TableValidator\"];\n\nexport type Indexes<TableDef extends AnyWithProps> = TableDef[\"indexes\"];\n\nexport type SearchIndexes<TableDef extends AnyWithProps> =\n TableDef[\"searchIndexes\"];\n\nexport type VectorIndexes<TableDef extends AnyWithProps> =\n TableDef[\"vectorIndexes\"];\n\nexport type Doc<TableDef extends AnyWithProps> = TableDef[\"Doc\"];\n\nexport type Fields<TableDef extends AnyWithProps> = TableDef[\"Fields\"];\nexport type Scope<TableDef extends AnyWithProps> = TableDef[\"scope\"];\n\nexport type WithName<\n TableDef extends AnyWithProps,\n Name_ extends string,\n> = TableDef extends { readonly tableName: Name_ } ? TableDef : never;\n\nexport type TablesRecord<Tables extends AnyWithProps> = {\n readonly [TableName_ in Name<Tables>]: WithName<Tables, TableName_>;\n};\n\n// -----------------------------------------------------------------------------\n// Construction\n// -----------------------------------------------------------------------------\n//\n// `make` only stores the user-supplied `lazyFields` callback alongside any\n// chained index metadata. Neither `Fields` nor `Doc` is constructed until\n// first access on a bound `Table`. Each chain step is O(1) (plain object\n// spread of the metadata records) and never invokes the callback. Binding\n// via `unnamed(tableName)` installs lazy memoised getters for `Fields` and\n// `Doc` via `Lazy.defineProperty`, so the first access materialises the\n// value and replaces the getter with a plain data property—second-and-\n// subsequent accesses are observably indistinguishable from a plain\n// property and avoid all function-call overhead.\n\ninterface UnnamedState<\n TableSchema_ extends Schema.Codec<any, any>,\n Indexes_ extends GenericTableIndexes,\n SearchIndexes_ extends GenericTableSearchIndexes,\n VectorIndexes_ extends GenericTableVectorIndexes,\n> {\n readonly lazyFields: () => TableSchema_;\n readonly indexes: Indexes_;\n readonly searchIndexes: SearchIndexes_;\n readonly vectorIndexes: VectorIndexes_;\n}\n\nconst makeBound = <\n Name_ extends string,\n TableSchema_ extends Schema.Codec<any, any>,\n TableValidator_ extends Validator<any, any, any>,\n Indexes_ extends GenericTableIndexes,\n SearchIndexes_ extends GenericTableSearchIndexes,\n VectorIndexes_ extends GenericTableVectorIndexes,\n Scope_ extends IdScope.IdScope,\n>(\n tableName: Name_,\n state: UnnamedState<TableSchema_, Indexes_, SearchIndexes_, VectorIndexes_>,\n scope: Scope_,\n): Table<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n> => {\n const bound = {\n [TypeId]: TypeId as TypeId,\n tableName,\n scope,\n indexes: state.indexes,\n searchIndexes: state.searchIndexes,\n vectorIndexes: state.vectorIndexes,\n } as Table<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n >;\n\n Lazy.defineProperty(bound, \"Fields\", () => state.lazyFields());\n\n Lazy.defineProperty(bound, \"Doc\", () =>\n SystemFields.extendWithSystemFields(\n tableName,\n (bound as { Fields: TableSchema_ }).Fields,\n scope,\n ),\n );\n\n return bound;\n};\n\nconst makeUnnamed = <\n TableSchema_ extends Schema.Codec<any, any>,\n TableValidator_ extends Validator<any, any, any>,\n Indexes_ extends GenericTableIndexes,\n SearchIndexes_ extends GenericTableSearchIndexes,\n VectorIndexes_ extends GenericTableVectorIndexes,\n>(\n state: UnnamedState<TableSchema_, Indexes_, SearchIndexes_, VectorIndexes_>,\n): UnnamedTable<\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_\n> => {\n type UnnamedTable_ = UnnamedTable<\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_\n >;\n\n type UnnamedTableFunction<FunctionName extends keyof UnnamedTable_> =\n UnnamedTable_[FunctionName];\n\n const bind = <\n const Name_ extends string,\n const Scope_ extends IdScope.IdScope = IdScope.App,\n >(\n tableName: Name_,\n scope?: Scope_,\n ): Table<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n > =>\n makeBound<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n >(tableName, state, (scope ?? IdScope.app) as Scope_);\n\n const index: UnnamedTableFunction<\"index\"> = (name, fields) =>\n makeUnnamed({\n lazyFields: state.lazyFields,\n indexes: {\n ...state.indexes,\n [name]: fields,\n } as any,\n searchIndexes: state.searchIndexes,\n vectorIndexes: state.vectorIndexes,\n });\n\n const searchIndex: UnnamedTableFunction<\"searchIndex\"> = (\n name,\n indexConfig,\n ) =>\n makeUnnamed({\n lazyFields: state.lazyFields,\n indexes: state.indexes,\n searchIndexes: {\n ...state.searchIndexes,\n [name]: indexConfig,\n } as any,\n vectorIndexes: state.vectorIndexes,\n });\n\n const vectorIndex: UnnamedTableFunction<\"vectorIndex\"> = (\n name,\n indexConfig,\n ) =>\n makeUnnamed({\n lazyFields: state.lazyFields,\n indexes: state.indexes,\n searchIndexes: state.searchIndexes,\n vectorIndexes: {\n ...state.vectorIndexes,\n [name]: indexConfig,\n } as any,\n });\n\n return Object.assign(bind, {\n [TypeId]: TypeId as TypeId,\n indexes: state.indexes,\n searchIndexes: state.searchIndexes,\n vectorIndexes: state.vectorIndexes,\n index,\n searchIndex,\n vectorIndex,\n }) as UnnamedTable_;\n};\n\nexport const make = <const TableSchema_ extends Schema.Codec<any, any>>(\n lazyFields: () => TableSchema_,\n): UnnamedTable<TableSchema_, TableSchemaToTableValidator<TableSchema_>> => {\n type TableValidator_ = TableSchemaToTableValidator<TableSchema_>;\n type UnnamedTable_ = UnnamedTable<TableSchema_, TableValidator_>;\n\n return makeUnnamed<TableSchema_, TableValidator_, {}, {}, {}>({\n lazyFields,\n indexes: {},\n searchIndexes: {},\n vectorIndexes: {},\n }) as UnnamedTable_;\n};\n\n// Vendored types from convex-js, partially modified. Ideally we could use these directly. See https://github.com/get-convex/convex-js/pull/14\n\n/**\n * Extract all of the index field paths within a Convex `Validator`.\n *\n * This is used when declaring table indexes.\n *\n * @public\n */\ntype ExtractFieldPaths<TableValidator_ extends Validator<any, any, any>> =\n // Add in the system fields available in index definitions.\n // This should be everything except for `_id` because thats added to indexes\n // automatically.\n TableValidator_[\"fieldPaths\"] | keyof ConvexSystemFields;\n"],"mappings":";;;;;;;;;;;;AAkBA,MAAa,SAAS;AActB,MAAa,WAAW,MACtB,UAAU,YAAY,GAAA,sBAAS,KAAK,UAAU,YAAY,GAAG,WAAW;AAE1E,MAAa,kBAAkB,MAC7B,UAAU,YAAY,GAAA,sBAAS,KAAK,CAAC,UAAU,YAAY,GAAG,WAAW;AA6O3E,MAAM,aASJ,WACA,OACA,UASG;CACH,MAAM,QAAQ;GACX,SAAS;EACV;EACA;EACA,SAAS,MAAM;EACf,eAAe,MAAM;EACrB,eAAe,MAAM;CACvB;CAUA,eAAoB,OAAO,gBAAgB,MAAM,WAAW,CAAC;CAE7D,eAAoB,OAAO,aACzBA,uBACE,WACC,MAAmC,QACpC,KACF,CACF;CAEA,OAAO;AACT;AAEA,MAAM,eAOJ,UAOG;CAYH,MAAM,QAIJ,WACA,UAUA,UAQE,WAAW,OAAQ,SAASC,GAAsB;CAEtD,MAAM,SAAwC,MAAM,WAClD,YAAY;EACV,YAAY,MAAM;EAClB,SAAS;GACP,GAAG,MAAM;IACR,OAAO;EACV;EACA,eAAe,MAAM;EACrB,eAAe,MAAM;CACvB,CAAC;CAEH,MAAM,eACJ,MACA,gBAEA,YAAY;EACV,YAAY,MAAM;EAClB,SAAS,MAAM;EACf,eAAe;GACb,GAAG,MAAM;IACR,OAAO;EACV;EACA,eAAe,MAAM;CACvB,CAAC;CAEH,MAAM,eACJ,MACA,gBAEA,YAAY;EACV,YAAY,MAAM;EAClB,SAAS,MAAM;EACf,eAAe,MAAM;EACrB,eAAe;GACb,GAAG,MAAM;IACR,OAAO;EACV;CACF,CAAC;CAEH,OAAO,OAAO,OAAO,MAAM;GACxB,SAAS;EACV,SAAS,MAAM;EACf,eAAe,MAAM;EACrB,eAAe,MAAM;EACrB;EACA;EACA;CACF,CAAC;AACH;AAEA,MAAa,QACX,eAC0E;CAI1E,OAAO,YAAuD;EAC5D;EACA,SAAS,CAAC;EACV,eAAe,CAAC;EAChB,eAAe,CAAC;CAClB,CAAC;AACH"}
1
+ {"version":3,"file":"Table.js","names":["SystemFields.extendWithSystemFields","IdScope.app"],"sources":["../src/Table.ts"],"sourcesContent":["import * as IdScope from \"./IdScope.js\";\nimport * as Lazy from \"./Lazy.js\";\nimport * as SystemFields from \"./SystemFields.js\";\nimport type { TableSchemaToTableValidator } from \"./SchemaToValidator.js\";\nimport type {\n SystemFields as ConvexSystemFields,\n Expand,\n GenericTableIndexes,\n GenericTableSearchIndexes,\n GenericTableVectorIndexes,\n IndexTiebreakerField,\n SearchIndexConfig,\n VectorIndexConfig,\n} from \"convex/server\";\nimport type { GenericValidator, Validator } from \"convex/values\";\nimport * as Predicate from \"effect/Predicate\";\nimport type * as Schema from \"effect/Schema\";\n\nexport const TypeId = \"~@confect/core/Table\";\nexport type TypeId = typeof TypeId;\n\n// -----------------------------------------------------------------------------\n// Predicates\n// -----------------------------------------------------------------------------\n//\n// Both bound `Table`s and `UnnamedTable` callables share the same `[TypeId]`\n// brand. They disambiguate by whether a `tableName` property is set: bound\n// tables have one, unnamed callables do not.\n//\n// The discriminator is `tableName` (not `name`) so it does not collide with\n// the built-in `Function.prototype.name` that every JS function carries.\n\nexport const isTable = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId) && Predicate.hasProperty(u, \"tableName\");\n\nexport const isUnnamedTable = (u: unknown): u is UnnamedAny =>\n Predicate.hasProperty(u, TypeId) && !Predicate.hasProperty(u, \"tableName\");\n\n// -----------------------------------------------------------------------------\n// Bound Table\n// -----------------------------------------------------------------------------\n//\n// A bound `Table` is the client-safe document schema: `Fields`, `Doc`, and\n// the index metadata records. The Convex deploy `tableDefinition` (which\n// value-imports `convex/server`) is produced separately by\n// `@confect/server/Table.tableDefinition`.\n\nexport interface Table<\n Name_ extends string,\n TableSchema_ extends Schema.Codec<any, any>,\n TableValidator_ extends GenericValidator =\n TableSchemaToTableValidator<TableSchema_>,\n Indexes_ extends GenericTableIndexes = {},\n SearchIndexes_ extends GenericTableSearchIndexes = {},\n VectorIndexes_ extends GenericTableVectorIndexes = {},\n Scope_ extends IdScope.IdScope = IdScope.App,\n> {\n readonly [TypeId]: TypeId;\n readonly tableName: Name_;\n readonly scope: Scope_;\n readonly Fields: TableSchema_;\n readonly Doc: SystemFields.ExtendWithSystemFields<\n Name_,\n TableSchema_,\n Scope_\n >;\n readonly indexes: Indexes_;\n readonly searchIndexes: SearchIndexes_;\n readonly vectorIndexes: VectorIndexes_;\n readonly \"~TableValidator\": TableValidator_;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n readonly tableName: string;\n}\n\nexport type AnyWithProps = Table<\n any,\n Schema.Codec<any, any>,\n GenericValidator,\n GenericTableIndexes,\n GenericTableSearchIndexes,\n GenericTableVectorIndexes,\n IdScope.IdScope\n>;\n\n// -----------------------------------------------------------------------------\n// UnnamedTable (callable)\n// -----------------------------------------------------------------------------\n//\n// `Table.make(lazyFields)` returns an `UnnamedTable`: a callable that\n// produces a fully bound `Table` when invoked with a name. Chaining methods\n// (`.index`, `.searchIndex`, `.vectorIndex`) live here and return new\n// `UnnamedTable`s, accumulating plain index metadata records. The\n// user-supplied `lazyFields` callback is just carried through until first\n// access of `Fields`/`Doc` on a bound table. The codegen pipeline emits a\n// wrapper file per user-authored table that simply invokes the unnamed\n// callable with the filename basename.\n\nexport interface UnnamedTable<\n TableSchema_ extends Schema.Codec<any, any>,\n TableValidator_ extends GenericValidator =\n TableSchemaToTableValidator<TableSchema_>,\n Indexes_ extends GenericTableIndexes = {},\n SearchIndexes_ extends GenericTableSearchIndexes = {},\n VectorIndexes_ extends GenericTableVectorIndexes = {},\n> {\n <\n const Name_ extends string,\n const Scope_ extends IdScope.IdScope = IdScope.App,\n >(\n tableName: Name_,\n scope?: Scope_,\n ): Table<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n >;\n\n readonly [TypeId]: TypeId;\n readonly indexes: Indexes_;\n readonly searchIndexes: SearchIndexes_;\n readonly vectorIndexes: VectorIndexes_;\n readonly \"~TableValidator\": TableValidator_;\n\n index<\n IndexName extends string,\n FirstFieldPath extends ExtractFieldPaths<TableValidator_>,\n RestFieldPaths extends ExtractFieldPaths<TableValidator_>[],\n >(\n name: IndexName,\n fields: [FirstFieldPath, ...RestFieldPaths],\n ): UnnamedTable<\n TableSchema_,\n TableValidator_,\n Expand<\n Indexes_ &\n Record<\n IndexName,\n [FirstFieldPath, ...RestFieldPaths, IndexTiebreakerField]\n >\n >,\n SearchIndexes_,\n VectorIndexes_\n >;\n\n searchIndex<\n IndexName extends string,\n SearchField extends ExtractFieldPaths<TableValidator_>,\n FilterFields extends ExtractFieldPaths<TableValidator_> = never,\n >(\n name: IndexName,\n indexConfig: Expand<SearchIndexConfig<SearchField, FilterFields>>,\n ): UnnamedTable<\n TableSchema_,\n TableValidator_,\n Indexes_,\n Expand<\n SearchIndexes_ &\n Record<\n IndexName,\n {\n searchField: SearchField;\n filterFields: FilterFields;\n }\n >\n >,\n VectorIndexes_\n >;\n\n vectorIndex<\n IndexName extends string,\n VectorField extends ExtractFieldPaths<TableValidator_>,\n FilterFields extends ExtractFieldPaths<TableValidator_> = never,\n >(\n name: IndexName,\n indexConfig: Expand<VectorIndexConfig<VectorField, FilterFields>>,\n ): UnnamedTable<\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n Expand<\n VectorIndexes_ &\n Record<\n IndexName,\n {\n vectorField: VectorField;\n dimensions: number;\n filterFields: FilterFields;\n }\n >\n >\n >;\n}\n\nexport interface UnnamedAny {\n readonly [TypeId]: TypeId;\n}\n\nexport type UnnamedAnyWithProps = UnnamedTable<\n Schema.Codec<any, any>,\n GenericValidator,\n GenericTableIndexes,\n GenericTableSearchIndexes,\n GenericTableVectorIndexes\n>;\n\n// -----------------------------------------------------------------------------\n// Type extractors\n// -----------------------------------------------------------------------------\n\nexport type Name<TableDef extends AnyWithProps> = TableDef[\"tableName\"] &\n string;\n\nexport type TableSchema<TableDef extends AnyWithProps> = TableDef[\"Fields\"];\n\nexport type TableValidator<TableDef extends AnyWithProps> =\n TableDef[\"~TableValidator\"];\n\nexport type Indexes<TableDef extends AnyWithProps> = TableDef[\"indexes\"];\n\nexport type SearchIndexes<TableDef extends AnyWithProps> =\n TableDef[\"searchIndexes\"];\n\nexport type VectorIndexes<TableDef extends AnyWithProps> =\n TableDef[\"vectorIndexes\"];\n\nexport type Doc<TableDef extends AnyWithProps> = TableDef[\"Doc\"];\n\nexport type Fields<TableDef extends AnyWithProps> = TableDef[\"Fields\"];\nexport type Scope<TableDef extends AnyWithProps> = TableDef[\"scope\"];\n\nexport type WithName<\n TableDef extends AnyWithProps,\n Name_ extends string,\n> = TableDef extends { readonly tableName: Name_ } ? TableDef : never;\n\nexport type TablesRecord<Tables extends AnyWithProps> = {\n readonly [TableName_ in Name<Tables>]: WithName<Tables, TableName_>;\n};\n\n// -----------------------------------------------------------------------------\n// Construction\n// -----------------------------------------------------------------------------\n//\n// `make` only stores the user-supplied `lazyFields` callback alongside any\n// chained index metadata. Neither `Fields` nor `Doc` is constructed until\n// first access on a bound `Table`. Each chain step is O(1) (plain object\n// spread of the metadata records) and never invokes the callback. Binding\n// via `unnamed(tableName)` installs lazy memoised getters for `Fields` and\n// `Doc` via `Lazy.defineProperty`, so the first access materialises the\n// value and replaces the getter with a plain data property—second-and-\n// subsequent accesses are observably indistinguishable from a plain\n// property and avoid all function-call overhead.\n\ninterface UnnamedState<\n TableSchema_ extends Schema.Codec<any, any>,\n Indexes_ extends GenericTableIndexes,\n SearchIndexes_ extends GenericTableSearchIndexes,\n VectorIndexes_ extends GenericTableVectorIndexes,\n> {\n readonly lazyFields: () => TableSchema_;\n readonly indexes: Indexes_;\n readonly searchIndexes: SearchIndexes_;\n readonly vectorIndexes: VectorIndexes_;\n}\n\nconst makeBound = <\n Name_ extends string,\n TableSchema_ extends Schema.Codec<any, any>,\n TableValidator_ extends Validator<any, any, any>,\n Indexes_ extends GenericTableIndexes,\n SearchIndexes_ extends GenericTableSearchIndexes,\n VectorIndexes_ extends GenericTableVectorIndexes,\n Scope_ extends IdScope.IdScope,\n>(\n tableName: Name_,\n state: UnnamedState<TableSchema_, Indexes_, SearchIndexes_, VectorIndexes_>,\n scope: Scope_,\n): Table<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n> => {\n const bound = {\n [TypeId]: TypeId as TypeId,\n tableName,\n scope,\n indexes: state.indexes,\n searchIndexes: state.searchIndexes,\n vectorIndexes: state.vectorIndexes,\n } as Table<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n >;\n\n Lazy.defineProperty(bound, \"Fields\", () => state.lazyFields());\n\n Lazy.defineProperty(bound, \"Doc\", () =>\n SystemFields.extendWithSystemFields(\n tableName,\n (bound as { Fields: TableSchema_ }).Fields,\n scope,\n ),\n );\n\n return bound;\n};\n\nconst makeUnnamed = <\n TableSchema_ extends Schema.Codec<any, any>,\n TableValidator_ extends Validator<any, any, any>,\n Indexes_ extends GenericTableIndexes,\n SearchIndexes_ extends GenericTableSearchIndexes,\n VectorIndexes_ extends GenericTableVectorIndexes,\n>(\n state: UnnamedState<TableSchema_, Indexes_, SearchIndexes_, VectorIndexes_>,\n): UnnamedTable<\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_\n> => {\n type UnnamedTable_ = UnnamedTable<\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_\n >;\n\n type UnnamedTableFunction<FunctionName extends keyof UnnamedTable_> =\n UnnamedTable_[FunctionName];\n\n const bind = <\n const Name_ extends string,\n const Scope_ extends IdScope.IdScope = IdScope.App,\n >(\n tableName: Name_,\n scope?: Scope_,\n ): Table<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n > =>\n makeBound<\n Name_,\n TableSchema_,\n TableValidator_,\n Indexes_,\n SearchIndexes_,\n VectorIndexes_,\n Scope_\n >(tableName, state, (scope ?? IdScope.app) as Scope_);\n\n const index: UnnamedTableFunction<\"index\"> = (name, fields) =>\n makeUnnamed({\n lazyFields: state.lazyFields,\n indexes: {\n ...state.indexes,\n [name]: fields,\n } as any,\n searchIndexes: state.searchIndexes,\n vectorIndexes: state.vectorIndexes,\n });\n\n const searchIndex: UnnamedTableFunction<\"searchIndex\"> = (\n name,\n indexConfig,\n ) =>\n makeUnnamed({\n lazyFields: state.lazyFields,\n indexes: state.indexes,\n searchIndexes: {\n ...state.searchIndexes,\n [name]: indexConfig,\n } as any,\n vectorIndexes: state.vectorIndexes,\n });\n\n const vectorIndex: UnnamedTableFunction<\"vectorIndex\"> = (\n name,\n indexConfig,\n ) =>\n makeUnnamed({\n lazyFields: state.lazyFields,\n indexes: state.indexes,\n searchIndexes: state.searchIndexes,\n vectorIndexes: {\n ...state.vectorIndexes,\n [name]: indexConfig,\n } as any,\n });\n\n return Object.assign(bind, {\n [TypeId]: TypeId as TypeId,\n indexes: state.indexes,\n searchIndexes: state.searchIndexes,\n vectorIndexes: state.vectorIndexes,\n index,\n searchIndex,\n vectorIndex,\n }) as UnnamedTable_;\n};\n\nexport const make = <const TableSchema_ extends Schema.Codec<any, any>>(\n lazyFields: () => TableSchema_,\n): UnnamedTable<TableSchema_, TableSchemaToTableValidator<TableSchema_>> => {\n type TableValidator_ = TableSchemaToTableValidator<TableSchema_>;\n type UnnamedTable_ = UnnamedTable<TableSchema_, TableValidator_>;\n\n return makeUnnamed<TableSchema_, TableValidator_, {}, {}, {}>({\n lazyFields,\n indexes: {},\n searchIndexes: {},\n vectorIndexes: {},\n }) as UnnamedTable_;\n};\n\n// Vendored types from convex-js, partially modified. Ideally we could use these directly. See https://github.com/get-convex/convex-js/pull/14\n\n/**\n * Extract all of the index field paths within a Convex `Validator`.\n *\n * This is used when declaring table indexes.\n *\n * @public\n */\ntype ExtractFieldPaths<TableValidator_ extends Validator<any, any, any>> =\n // Add in the system fields available in index definitions.\n // This should be everything except for `_id` because thats added to indexes\n // automatically.\n TableValidator_[\"fieldPaths\"] | keyof ConvexSystemFields;\n"],"mappings":";;;;;;;;;;;;AAkBA,MAAa,SAAS;AActB,MAAa,WAAW,MACtB,UAAU,YAAY,GAAA,sBAAS,KAAK,UAAU,YAAY,GAAG,WAAW;AAE1E,MAAa,kBAAkB,MAC7B,UAAU,YAAY,GAAA,sBAAS,KAAK,CAAC,UAAU,YAAY,GAAG,WAAW;AA6O3E,MAAM,aASJ,WACA,OACA,UASG;CACH,MAAM,QAAQ;GACX,SAAS;EACV;EACA;EACA,SAAS,MAAM;EACf,eAAe,MAAM;EACrB,eAAe,MAAM;CACvB;CAUA,eAAoB,OAAO,gBAAgB,MAAM,WAAW,CAAC;CAE7D,eAAoB,OAAO,aACzBA,uBACE,WACC,MAAmC,QACpC,KACF,CACF;CAEA,OAAO;AACT;AAEA,MAAM,eAOJ,UAOG;CAYH,MAAM,QAIJ,WACA,UAUA,UAQE,WAAW,OAAQ,SAASC,GAAsB;CAEtD,MAAM,SAAwC,MAAM,WAClD,YAAY;EACV,YAAY,MAAM;EAClB,SAAS;GACP,GAAG,MAAM;IACR,OAAO;EACV;EACA,eAAe,MAAM;EACrB,eAAe,MAAM;CACvB,CAAC;CAEH,MAAM,eACJ,MACA,gBAEA,YAAY;EACV,YAAY,MAAM;EAClB,SAAS,MAAM;EACf,eAAe;GACb,GAAG,MAAM;IACR,OAAO;EACV;EACA,eAAe,MAAM;CACvB,CAAC;CAEH,MAAM,eACJ,MACA,gBAEA,YAAY;EACV,YAAY,MAAM;EAClB,SAAS,MAAM;EACf,eAAe,MAAM;EACrB,eAAe;GACb,GAAG,MAAM;IACR,OAAO;EACV;CACF,CAAC;CAEH,OAAO,OAAO,OAAO,MAAM;GACxB,SAAS;EACV,SAAS,MAAM;EACf,eAAe,MAAM;EACrB,eAAe,MAAM;EACrB;EACA;EACA;CACF,CAAC;AACH;AAEA,MAAa,QACX,eAC0E;CAI1E,OAAO,YAAuD;EAC5D;EACA,SAAS,CAAC;EACV,eAAe,CAAC;EAChB,eAAe,CAAC;CAClB,CAAC;AACH"}
package/dist/index.d.ts CHANGED
@@ -1,30 +1,32 @@
1
- export * as Callback from "./Callback";
2
- export * as FunctionProvenance from "./FunctionProvenance";
3
- export * as FunctionSpec from "./FunctionSpec";
4
- export * as GenericId from "./GenericId";
5
- export * as App from "./App";
6
- export * as Auth from "./Auth";
7
- export * as Component from "./Component";
8
- export * as Env from "./Env";
9
- export * as Http from "./Http";
10
- export * as IdScope from "./IdScope";
11
- export * as GroupPath from "./GroupPath";
12
- export * as GroupSpec from "./GroupSpec";
13
- export * as Identifier from "./Identifier";
14
- export * as Lazy from "./Lazy";
15
- export * as Manifest from "./Manifest";
16
- export * as MiddlewareAttachment from "./MiddlewareAttachment";
17
- export * as MiddlewareSpec from "./MiddlewareSpec";
18
- export * as PaginationError from "./PaginationError";
19
- export * as PaginationOptions from "./PaginationOptions";
20
- export * as PaginationResult from "./PaginationResult";
21
- export * as Ref from "./Ref";
22
- export * as Refs from "./Refs";
23
- export * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
24
- export * as SchemaToValidator from "./SchemaToValidator";
25
- export * as Spec from "./Spec";
26
- export * as SystemFields from "./SystemFields";
27
- export * as Table from "./Table";
28
- export * as Types from "./Types";
29
- export * as UserIdentity from "./UserIdentity";
1
+ export * as ActionCall from "./ActionCall.js";
2
+ export * as Callback from "./Callback.js";
3
+ export * as FunctionProvenance from "./FunctionProvenance.js";
4
+ export * as FunctionSpec from "./FunctionSpec.js";
5
+ export * as GenericId from "./GenericId.js";
6
+ export * as App from "./App.js";
7
+ export * as Auth from "./Auth.js";
8
+ export * as Component from "./Component.js";
9
+ export * as Env from "./Env.js";
10
+ export * as Http from "./Http.js";
11
+ export * as IdScope from "./IdScope.js";
12
+ export * as GroupPath from "./GroupPath.js";
13
+ export * as GroupSpec from "./GroupSpec.js";
14
+ export * as Identifier from "./Identifier.js";
15
+ export * as Lazy from "./Lazy.js";
16
+ export * as Manifest from "./Manifest.js";
17
+ export * as MiddlewareAttachment from "./MiddlewareAttachment.js";
18
+ export * as MiddlewareSpec from "./MiddlewareSpec.js";
19
+ export * as PaginationError from "./PaginationError.js";
20
+ export * as PaginationOptions from "./PaginationOptions.js";
21
+ export * as PaginationResult from "./PaginationResult.js";
22
+ export * as Profile from "./Profile.js";
23
+ export * as Ref from "./Ref.js";
24
+ export * as Refs from "./Refs.js";
25
+ export * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
26
+ export * as SchemaToValidator from "./SchemaToValidator.js";
27
+ export * as Spec from "./Spec.js";
28
+ export * as SystemFields from "./SystemFields.js";
29
+ export * as Table from "./Table.js";
30
+ export * as Types from "./Types.js";
31
+ export * as UserIdentity from "./UserIdentity.js";
30
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,kBAAkB,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,oBAAoB,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,iBAAiB,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,gBAAgB,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,sBAAsB,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,iBAAiB,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,oBAAoB,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -1,30 +1,32 @@
1
- import { App_exports } from "./App.js";
2
- import { Auth_exports } from "./Auth.js";
3
1
  import { Lazy_exports } from "./Lazy.js";
4
2
  import { PaginationOptions_exports } from "./PaginationOptions.js";
5
3
  import { PaginationResult_exports } from "./PaginationResult.js";
6
4
  import { FunctionProvenance_exports } from "./FunctionProvenance.js";
5
+ import { Identifier_exports } from "./Identifier.js";
7
6
  import { MiddlewareSpec_exports } from "./MiddlewareSpec.js";
7
+ import { RuntimeAndFunctionType_exports } from "./RuntimeAndFunctionType.js";
8
+ import { FunctionSpec_exports } from "./FunctionSpec.js";
9
+ import { ActionCall_exports } from "./ActionCall.js";
10
+ import { App_exports } from "./App.js";
11
+ import { Auth_exports } from "./Auth.js";
8
12
  import { Ref_exports } from "./Ref.js";
9
13
  import { Callback_exports } from "./Callback.js";
10
14
  import { IdScope_exports } from "./IdScope.js";
11
15
  import { GenericId_exports } from "./GenericId.js";
12
16
  import { MiddlewareAttachment_exports } from "./MiddlewareAttachment.js";
13
- import { Identifier_exports } from "./Identifier.js";
14
17
  import { GroupSpec_exports } from "./GroupSpec.js";
15
18
  import { Spec_exports } from "./Spec.js";
16
19
  import { Component_exports } from "./Component.js";
17
20
  import { Env_exports } from "./Env.js";
18
- import { RuntimeAndFunctionType_exports } from "./RuntimeAndFunctionType.js";
19
- import { FunctionSpec_exports } from "./FunctionSpec.js";
20
21
  import { GroupPath_exports } from "./GroupPath.js";
21
22
  import { Http_exports } from "./Http.js";
22
23
  import { Manifest_exports } from "./Manifest.js";
23
24
  import { PaginationError_exports } from "./PaginationError.js";
25
+ import { Profile_exports } from "./Profile.js";
24
26
  import { Refs_exports } from "./Refs.js";
25
27
  import { SchemaToValidator_exports } from "./SchemaToValidator.js";
26
28
  import { SystemFields_exports } from "./SystemFields.js";
27
29
  import { Table_exports } from "./Table.js";
28
30
  import { Types_exports } from "./Types.js";
29
31
  import { UserIdentity_exports } from "./UserIdentity.js";
30
- export { App_exports as App, Auth_exports as Auth, Callback_exports as Callback, Component_exports as Component, Env_exports as Env, FunctionProvenance_exports as FunctionProvenance, FunctionSpec_exports as FunctionSpec, GenericId_exports as GenericId, GroupPath_exports as GroupPath, GroupSpec_exports as GroupSpec, Http_exports as Http, IdScope_exports as IdScope, Identifier_exports as Identifier, Lazy_exports as Lazy, Manifest_exports as Manifest, MiddlewareAttachment_exports as MiddlewareAttachment, MiddlewareSpec_exports as MiddlewareSpec, PaginationError_exports as PaginationError, PaginationOptions_exports as PaginationOptions, PaginationResult_exports as PaginationResult, Ref_exports as Ref, Refs_exports as Refs, RuntimeAndFunctionType_exports as RuntimeAndFunctionType, SchemaToValidator_exports as SchemaToValidator, Spec_exports as Spec, SystemFields_exports as SystemFields, Table_exports as Table, Types_exports as Types, UserIdentity_exports as UserIdentity };
32
+ export { ActionCall_exports as ActionCall, App_exports as App, Auth_exports as Auth, Callback_exports as Callback, Component_exports as Component, Env_exports as Env, FunctionProvenance_exports as FunctionProvenance, FunctionSpec_exports as FunctionSpec, GenericId_exports as GenericId, GroupPath_exports as GroupPath, GroupSpec_exports as GroupSpec, Http_exports as Http, IdScope_exports as IdScope, Identifier_exports as Identifier, Lazy_exports as Lazy, Manifest_exports as Manifest, MiddlewareAttachment_exports as MiddlewareAttachment, MiddlewareSpec_exports as MiddlewareSpec, PaginationError_exports as PaginationError, PaginationOptions_exports as PaginationOptions, PaginationResult_exports as PaginationResult, Profile_exports as Profile, Ref_exports as Ref, Refs_exports as Refs, RuntimeAndFunctionType_exports as RuntimeAndFunctionType, SchemaToValidator_exports as SchemaToValidator, Spec_exports as Spec, SystemFields_exports as SystemFields, Table_exports as Table, Types_exports as Types, UserIdentity_exports as UserIdentity };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@gaganref/confect-core",
3
- "version": "10.3.1-fork.4",
3
+ "version": "10.3.1-fork.40",
4
4
  "peerDependencies": {
5
- "convex": "^1.46.0",
6
- "effect": "^4.0.0"
5
+ "convex": "^1.48.0",
6
+ "effect": ">=4.0.0 <4.1.0"
7
7
  },
8
8
  "description": "Shared specs and schemas used by all Confect packages",
9
9
  "author": "RJ Dellecese",
@@ -0,0 +1,25 @@
1
+ import * as Context from "effect/Context";
2
+ import type * as Effect from "effect/Effect";
3
+ import type * as Schema from "effect/Schema";
4
+ import * as FunctionSpec from "./FunctionSpec.js";
5
+ import * as MiddlewareSpec from "./MiddlewareSpec.js";
6
+ import type * as Ref from "./Ref.js";
7
+
8
+ export interface Call {
9
+ <Target extends Ref.AnyQuery | Ref.AnyMutation>(
10
+ target: Target,
11
+ ...args: Ref.OptionalArgs<NoInfer<Target>>
12
+ ): Effect.Effect<Ref.Returns<Target>, Ref.Error<Target> | Schema.SchemaError>;
13
+ }
14
+
15
+ export class ActionCall extends Context.Service<ActionCall, Call>()(
16
+ "@confect/core/ActionCall",
17
+ ) {}
18
+ export class Middleware extends MiddlewareSpec.MiddlewareSpec<
19
+ Middleware,
20
+ { provides: ActionCall }
21
+ >()("@confect/core/ActionCall/Middleware", {
22
+ functionTypes: { query: false, mutation: false, action: true },
23
+ }) {}
24
+
25
+ export const profile = FunctionSpec.extend()({ middleware: [Middleware] });
package/src/App.ts CHANGED
@@ -2,7 +2,8 @@ import type { ComponentDefinition, EnvDefinition } from "convex/server";
2
2
  import type { Infer, Validator } from "convex/values";
3
3
  import type * as HttpApi from "effect/http-api/HttpApi";
4
4
  import * as Predicate from "effect/Predicate";
5
- import type * as Env from "./Env";
5
+ import type * as Env from "./Env.js";
6
+ import type * as MiddlewareSpec from "./MiddlewareSpec.js";
6
7
 
7
8
  const TypeId = "~@confect/core/App";
8
9
  const MountTypeId = "~@confect/core/App/Mount";
@@ -48,13 +49,21 @@ type HttpOptions =
48
49
  | { readonly httpPrefix?: never; readonly api?: never }
49
50
  | { readonly httpPrefix: HttpPrefix; readonly api?: Api };
50
51
 
51
- export type Options<D extends Definition> = HttpOptions &
52
- ([RequiredKeys<EnvOf<D>>] extends [never]
52
+ export type Options<D extends Definition> = HttpOptions & {
53
+ /**
54
+ * The package specifier of the module whose `register(t, name)` the generated
55
+ * test registry calls for this mount, in place of the component package's own
56
+ * `<package>/test`. The kit registers the mount's children.
57
+ */
58
+ readonly testing?: string;
59
+ } & ([RequiredKeys<EnvOf<D>>] extends [never]
53
60
  ? { readonly env?: Bindings<EnvOf<D>> }
54
61
  : { readonly env: Bindings<EnvOf<D>> });
55
62
 
56
63
  type Exact<D extends Definition, O> = {
57
- readonly [K in Exclude<keyof O, "env" | "httpPrefix" | "api">]: never;
64
+ readonly [
65
+ K in Exclude<keyof O, "env" | "httpPrefix" | "api" | "testing">
66
+ ]: never;
58
67
  } & (O extends { readonly env: infer B }
59
68
  ? {
60
69
  readonly env: { readonly [K in Exclude<keyof B, keyof EnvOf<D>>]: never };
@@ -66,6 +75,7 @@ export interface MountData {
66
75
  readonly httpPrefix: HttpPrefix | undefined;
67
76
  readonly api: Api | undefined;
68
77
  readonly env: Readonly<Record<string, string | Env.AnyEntry | undefined>>;
78
+ readonly testing: string | undefined;
69
79
  }
70
80
 
71
81
  /**
@@ -106,6 +116,7 @@ export function mount(
106
116
  readonly httpPrefix?: HttpPrefix;
107
117
  readonly api?: Api;
108
118
  readonly env?: MountData["env"];
119
+ readonly testing?: string;
109
120
  },
110
121
  ): AnyMount {
111
122
  return {
@@ -114,6 +125,7 @@ export function mount(
114
125
  httpPrefix: options?.httpPrefix,
115
126
  api: options?.api,
116
127
  env: options?.env ?? {},
128
+ testing: options?.testing,
117
129
  // The overloads above carry the precise types; this body serves both.
118
130
  } as AnyMount;
119
131
  }
@@ -144,6 +156,7 @@ export interface App<
144
156
  readonly kind: K;
145
157
  readonly env: E;
146
158
  readonly mounts: M;
159
+ readonly requiresMiddleware: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;
147
160
  }
148
161
 
149
162
  export type Any = App<Env.Any, Readonly<Record<string, AnyMount>>>;
@@ -175,6 +188,7 @@ export const make = <
175
188
  >(
176
189
  options: {
177
190
  readonly env: E;
191
+ readonly requiresMiddleware?: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;
178
192
  readonly mounts?: M & OwnedBy<NoInfer<Env.Name<E>>, NoInfer<M>>;
179
193
  } & ([K] extends ["app"] ? { readonly kind?: K } : { readonly kind: K }),
180
194
  ): App<E, M, K> => ({
@@ -182,6 +196,7 @@ export const make = <
182
196
  kind: options.kind ?? ("app" as K),
183
197
  env: options.env,
184
198
  mounts: options.mounts ?? ({} as M),
199
+ requiresMiddleware: options.requiresMiddleware ?? [],
185
200
  });
186
201
 
187
202
  export const isApp = (u: unknown): u is Any =>
@@ -207,4 +222,5 @@ export const mounts = (
207
222
  httpPrefix: installed.httpPrefix,
208
223
  api: installed.api,
209
224
  env: installed.env,
225
+ testing: installed.testing,
210
226
  }));
package/src/Auth.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import type { AuthProvider } from "convex/server";
2
2
  import * as Predicate from "effect/Predicate";
3
- import type * as App from "./App";
4
- import type { TypeError } from "./Types";
3
+ import type * as App from "./App.js";
4
+ import type * as Env from "./Env.js";
5
+ import type { TypeError } from "./Types.js";
5
6
 
6
7
  const TypeId = "~@confect/core/Auth";
8
+ const CloudUrlTypeId = "~@confect/core/Auth/CloudUrl";
7
9
  const SiteUrlTypeId = "~@confect/core/Auth/SiteUrl";
8
10
 
9
11
  /**
@@ -15,19 +17,59 @@ export interface SiteUrl {
15
17
  readonly path: string;
16
18
  }
17
19
 
18
- type Url = string | SiteUrl;
20
+ /**
21
+ * The deployment's cloud URL (`CONVEX_CLOUD_URL`) plus a path.
22
+ */
23
+ export interface CloudUrl {
24
+ readonly [CloudUrlTypeId]: typeof CloudUrlTypeId;
25
+ readonly path: string;
26
+ }
19
27
 
20
- type WithSiteUrl<P> = P extends unknown
28
+ type Url =
29
+ | string
30
+ | SiteUrl
31
+ | CloudUrl
32
+ | Env.Entry<string, string, string, false>;
33
+
34
+ type WithUrls<P> = P extends unknown
21
35
  ? {
22
- [K in keyof P]: K extends "domain" | "issuer" | "jwks" ? Url : P[K];
36
+ [K in keyof P]: K extends "domain" | "issuer" | "jwks" | "applicationID"
37
+ ? Url
38
+ : P[K];
23
39
  }
24
40
  : never;
25
41
 
26
42
  /**
27
- * Convex's `AuthProvider`, with `domain`, `issuer` and `jwks` also taking a
28
- * {@link SiteUrl}.
43
+ * Convex's provider list with deployment URLs and required, public env strings.
44
+ */
45
+ export type Provider = WithUrls<AuthProvider> & {
46
+ /**
47
+ * Application-defined token family, copied to the runtime provider data.
48
+ */
49
+ readonly family?: string;
50
+ /**
51
+ * Application-defined issuer name, for example a trusted service.
52
+ */
53
+ readonly name?: string;
54
+ };
55
+
56
+ /**
57
+ * The cloud URL, or a path under it, resolved when Convex loads auth config.
29
58
  */
30
- export type Provider = WithSiteUrl<AuthProvider>;
59
+ export const cloudUrl = (path: `/${string}` | "" = ""): CloudUrl => ({
60
+ [CloudUrlTypeId]: CloudUrlTypeId,
61
+ path,
62
+ });
63
+
64
+ /**
65
+ * The path of a cloud URL placeholder, or `undefined` for another value.
66
+ */
67
+ export const cloudUrlPath = (u: unknown): string | undefined =>
68
+ Predicate.hasProperty(u, CloudUrlTypeId) &&
69
+ Predicate.hasProperty(u, "path") &&
70
+ typeof u.path === "string"
71
+ ? u.path
72
+ : undefined;
31
73
 
32
74
  export interface Auth<A extends App.Any> {
33
75
  readonly [TypeId]: typeof TypeId;
package/src/Callback.ts CHANGED
@@ -6,9 +6,9 @@ import type {
6
6
  import * as Predicate from "effect/Predicate";
7
7
  import * as Schema from "effect/Schema";
8
8
  import * as SchemaGetter from "effect/SchemaGetter";
9
- import * as FunctionProvenance from "./FunctionProvenance";
10
- import * as Ref from "./Ref";
11
- import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
9
+ import * as FunctionProvenance from "./FunctionProvenance.js";
10
+ import * as Ref from "./Ref.js";
11
+ import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
12
12
 
13
13
  export const TypeId = "~@confect/core/Callback";
14
14
  export type TypeId = typeof TypeId;
@@ -145,6 +145,7 @@ const fromText = <Contract_ extends Any>(
145
145
  [],
146
146
  // Convex types a handle as a string that is also a function reference.
147
147
  text as unknown as FunctionReference<any, any>,
148
+ contract.functionType,
148
149
  ),
149
150
  { [HandleTypeId]: contract.id },
150
151
  ) as unknown as Handle<Contract_>;
package/src/Component.ts CHANGED
@@ -7,17 +7,17 @@ import { memoize, pipe } from "effect/Function";
7
7
  import * as Match from "effect/Match";
8
8
  import * as Record from "effect/Record";
9
9
  import * as Schema from "effect/Schema";
10
- import type * as FunctionProvenance from "./FunctionProvenance";
11
- import type * as FunctionSpec from "./FunctionSpec";
12
- import * as GenericId from "./GenericId";
13
- import type * as GroupSpec from "./GroupSpec";
14
- import * as IdScope from "./IdScope";
15
- import * as Lazy from "./Lazy";
16
- import type * as MiddlewareSpec from "./MiddlewareSpec";
17
- import * as Ref from "./Ref";
18
- import type * as Refs from "./Refs";
19
- import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
20
- import * as Spec from "./Spec";
10
+ import type * as FunctionProvenance from "./FunctionProvenance.js";
11
+ import type * as FunctionSpec from "./FunctionSpec.js";
12
+ import * as GenericId from "./GenericId.js";
13
+ import type * as GroupSpec from "./GroupSpec.js";
14
+ import * as IdScope from "./IdScope.js";
15
+ import * as Lazy from "./Lazy.js";
16
+ import type * as MiddlewareSpec from "./MiddlewareSpec.js";
17
+ import * as Ref from "./Ref.js";
18
+ import type * as Refs from "./Refs.js";
19
+ import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
20
+ import * as Spec from "./Spec.js";
21
21
 
22
22
  export class EmptyComponentScopeError extends Data.TaggedError(
23
23
  "EmptyComponentScopeError",
@@ -358,6 +358,7 @@ export const bind = <
358
358
  spec: rebaseMiddleware(attachment.spec),
359
359
  })),
360
360
  nativeRef,
361
+ ref.functionType,
361
362
  );
362
363
  }),
363
364
  Match.exhaustive,
@@ -1,9 +1,9 @@
1
1
  import type { DefaultFunctionArgs } from "convex/server";
2
2
  import * as Data from "effect/Data";
3
3
  import * as Schema from "effect/Schema";
4
- import * as Lazy from "./Lazy";
5
- import * as PaginationOptions from "./PaginationOptions";
6
- import * as PaginationResult from "./PaginationResult";
4
+ import * as Lazy from "./Lazy.js";
5
+ import * as PaginationOptions from "./PaginationOptions.js";
6
+ import * as PaginationResult from "./PaginationResult.js";
7
7
 
8
8
  /**
9
9
  * A field map accepted as Confect function args. Restricting each field to a