@prisma-next/ids 0.5.0-dev.9 → 0.5.0

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.
package/dist/index.d.mts CHANGED
@@ -5,7 +5,7 @@ import { ulid as ulid$1 } from "uniku/ulid";
5
5
  import { uuidv4 as uuidv4$1 } from "uniku/uuid/v4";
6
6
  import { uuidv7 as uuidv7$1 } from "uniku/uuid/v7";
7
7
  import { ExecutionMutationDefaultValue } from "@prisma-next/contract/types";
8
- import { ColumnTypeDescriptor } from "@prisma-next/contract-authoring";
8
+ import { ColumnTypeDescriptor } from "@prisma-next/framework-components/codec";
9
9
 
10
10
  //#region src/generator-ids.d.ts
11
11
  declare const builtinGeneratorIds: readonly ["ulid", "nanoid", "uuidv7", "uuidv4", "cuid2", "ksuid"];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/generator-ids.ts","../src/generators.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAAa;KASD,kBAAA,WAA6B;;;KCDpC,sBAAsB,uFAGrB;KAGM,sBAAA;iBACK,gBAAgB;mBACd,gBAAgB;EDhBtB,SAAA,MAAA,ECiBM,QDVT,CAAA,OCUyB,QDVzB,CAAA;EAEE,SAAA,MAAA,ECSO,QDTW,CAAA,OCSK,QDTM,CAAA;kBCUvB,gBAAgB;kBAChB,gBAAgB;;;;KCZtB,yBAAA;iBACK;wBACO;;cA8EX,kCAAkC;EFxFlC,SAAA,EAAA,EEyFE,kBFlFL;EAEE,SAAA,kBAAkB,EAAA,SAAW,MAAA,EAAA;;iBEuFzB,uCAAA;eACD;EDzFV,SAAA,MAAQ,CAAA,EC0FO,MD1FP,CAAA,MAAA,EAAc,OAAA,CAAA;AAM3B,CAAA,CAAA,ECqFI,yBDrF8B;AACD,KC4FrB,mBD5FqB,CAAA,iBAAA,MAAA,GAAA,MAAA,CAAA,GAAA;EAAhB,SAAA,IAAA,EC6FA,oBD7FA,CC6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A,EAAQ,QAAA,QAAgB,QAAA;EAAA,SACxB,MAAA,EAAQ,QAAA,QAAgB,QAAA;EAAA,SACxB,KAAA,EAAO,QAAA,QAAgB,OAAA;EAAA,SACvB,KAAA,EAAO,QAAA,QAAgB,OAAA;AAAA;;;KCZtB,yBAAA;EAAA,SACD,IAAA,EAAM,oBAAA;EAAA,SACN,UAAA,GAAa,MAAA;AAAA;AAAA,cA8EX,gCAAA,EAAkC,aAAA;EAAA,SACpC,EAAA,EAAI,kBAAA;EAAA,SACJ,kBAAA;AAAA;AAAA,iBAMK,uCAAA,CAAwC,KAAA;EAAA,SAC7C,EAAA,EAAI,kBAAA;EAAA,SACJ,MAAA,GAAS,MAAA;AAAA,IAChB,yBAAA;AAAA,KAQQ,mBAAA;EAAA,SACD,IAAA,EAAM,oBAAA,CAAqB,QAAA;EAAA,SAC3B,QAAA;EAAA,SACA,UAAA,GAAa,MAAA;EAAA,SACb,SAAA,EAAW,6BAAA;AAAA;AAAA,cA2BT,IAAA,GAAQ,OAAA,GAAU,sBAAA,aAA8B,mBAAA;AAAA,cAEhD,MAAA,GAAU,OAAA,GAAU,sBAAA,eAAgC,mBAAA;AAAA,cAEpD,MAAA,GAAU,OAAA,GAAU,sBAAA,eAAgC,mBAAA;AAAA,cAEpD,MAAA,GAAU,OAAA,GAAU,sBAAA,eAAgC,mBAAA;AAAA,cAEpD,KAAA,GAAS,OAAA,GAAU,sBAAA,cAA+B,mBAAA;AAAA,cAElD,KAAA,GAAS,OAAA,GAAU,sBAAA,cAA+B,mBAAA"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import { ifDefined } from "@prisma-next/utils/defined";
2
-
3
2
  //#region src/generator-ids.ts
4
3
  const builtinGeneratorIds = [
5
4
  "ulid",
@@ -9,7 +8,6 @@ const builtinGeneratorIds = [
9
8
  "cuid2",
10
9
  "ksuid"
11
10
  ];
12
-
13
11
  //#endregion
14
12
  //#region src/index.ts
15
13
  function resolveNanoidColumnDescriptor(params) {
@@ -125,7 +123,7 @@ const uuidv7 = (options) => createGeneratedSpec("uuidv7", options);
125
123
  const uuidv4 = (options) => createGeneratedSpec("uuidv4", options);
126
124
  const cuid2 = (options) => createGeneratedSpec("cuid2", options);
127
125
  const ksuid = (options) => createGeneratedSpec("ksuid", options);
128
-
129
126
  //#endregion
130
127
  export { builtinGeneratorIds, builtinGeneratorRegistryMetadata, cuid2, ksuid, nanoid, resolveBuiltinGeneratedColumnDescriptor, ulid, uuidv4, uuidv7 };
128
+
131
129
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["builtinGeneratorRegistryMetadata: ReadonlyArray<{\n readonly id: BuiltinGeneratorId;\n readonly applicableCodecIds: readonly string[];\n}>","metadata: BuiltinGeneratorMetadata"],"sources":["../src/generator-ids.ts","../src/index.ts"],"sourcesContent":["export const builtinGeneratorIds = [\n 'ulid',\n 'nanoid',\n 'uuidv7',\n 'uuidv4',\n 'cuid2',\n 'ksuid',\n] as const;\n\nexport type BuiltinGeneratorId = (typeof builtinGeneratorIds)[number];\n","import type { ExecutionMutationDefaultValue } from '@prisma-next/contract/types';\nimport type { ColumnTypeDescriptor } from '@prisma-next/contract-authoring';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { type BuiltinGeneratorId, builtinGeneratorIds } from './generator-ids';\nimport type { IdGeneratorOptionsById } from './generators';\n\nexport { builtinGeneratorIds };\n\nexport type GeneratedColumnDescriptor = {\n readonly type: ColumnTypeDescriptor;\n readonly typeParams?: Record<string, unknown>;\n};\n\ntype BuiltinGeneratorMetadata = {\n readonly applicableCodecIds: readonly string[];\n readonly generatedColumnDescriptor: GeneratedColumnDescriptor;\n readonly resolveGeneratedColumnDescriptor?: (\n params?: Record<string, unknown>,\n ) => GeneratedColumnDescriptor;\n};\n\nfunction resolveNanoidColumnDescriptor(\n params?: Record<string, unknown>,\n): GeneratedColumnDescriptor {\n const rawSize = params?.['size'];\n if (rawSize === undefined) {\n return {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 21 },\n };\n }\n\n if (typeof rawSize !== 'number' || !Number.isInteger(rawSize) || rawSize < 2 || rawSize > 255) {\n throw new Error('nanoid size must be an integer between 2 and 255');\n }\n\n return {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: rawSize },\n };\n}\n\nconst builtinGeneratorMetadataById = {\n ulid: {\n applicableCodecIds: ['pg/text@1', 'sql/char@1'],\n generatedColumnDescriptor: {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 26 },\n },\n },\n nanoid: {\n applicableCodecIds: ['pg/text@1', 'sql/char@1'],\n generatedColumnDescriptor: {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 21 },\n },\n resolveGeneratedColumnDescriptor: resolveNanoidColumnDescriptor,\n },\n uuidv7: {\n applicableCodecIds: ['pg/text@1', 'sql/char@1'],\n generatedColumnDescriptor: {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 36 },\n },\n },\n uuidv4: {\n applicableCodecIds: ['pg/text@1', 'sql/char@1'],\n generatedColumnDescriptor: {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 36 },\n },\n },\n cuid2: {\n applicableCodecIds: ['pg/text@1', 'sql/char@1'],\n generatedColumnDescriptor: {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 24 },\n },\n },\n ksuid: {\n applicableCodecIds: ['pg/text@1', 'sql/char@1'],\n generatedColumnDescriptor: {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 27 },\n },\n },\n} as const satisfies Record<BuiltinGeneratorId, BuiltinGeneratorMetadata>;\n\nexport const builtinGeneratorRegistryMetadata: ReadonlyArray<{\n readonly id: BuiltinGeneratorId;\n readonly applicableCodecIds: readonly string[];\n}> = builtinGeneratorIds.map((id) => ({\n id,\n applicableCodecIds: builtinGeneratorMetadataById[id].applicableCodecIds,\n}));\n\nexport function resolveBuiltinGeneratedColumnDescriptor(input: {\n readonly id: BuiltinGeneratorId;\n readonly params?: Record<string, unknown>;\n}): GeneratedColumnDescriptor {\n const metadata: BuiltinGeneratorMetadata = builtinGeneratorMetadataById[input.id];\n if (metadata.resolveGeneratedColumnDescriptor) {\n return metadata.resolveGeneratedColumnDescriptor(input.params);\n }\n return metadata.generatedColumnDescriptor;\n}\n\nexport type GeneratedColumnSpec<TCodecId extends string = string> = {\n readonly type: ColumnTypeDescriptor<TCodecId>;\n readonly nullable?: false;\n readonly typeParams?: Record<string, unknown>;\n readonly generated: ExecutionMutationDefaultValue;\n};\n\ntype GeneratorCodecId<TId extends BuiltinGeneratorId> =\n (typeof builtinGeneratorMetadataById)[TId]['generatedColumnDescriptor']['type']['codecId'];\n\nfunction createGeneratedSpec<TId extends BuiltinGeneratorId>(\n id: TId,\n options?: IdGeneratorOptionsById[TId],\n): GeneratedColumnSpec<GeneratorCodecId<TId>> {\n const params = options as Record<string, unknown> | undefined;\n const resolvedDescriptor = resolveBuiltinGeneratedColumnDescriptor({\n id,\n ...ifDefined('params', params),\n });\n return {\n type: resolvedDescriptor.type,\n nullable: false,\n ...ifDefined('typeParams', resolvedDescriptor.typeParams),\n generated: {\n kind: 'generator',\n id,\n ...ifDefined('params', params),\n },\n } as GeneratedColumnSpec<GeneratorCodecId<TId>>;\n}\n\nexport const ulid = (options?: IdGeneratorOptionsById['ulid']) =>\n createGeneratedSpec('ulid', options);\nexport const nanoid = (options?: IdGeneratorOptionsById['nanoid']) =>\n createGeneratedSpec('nanoid', options);\nexport const uuidv7 = (options?: IdGeneratorOptionsById['uuidv7']) =>\n createGeneratedSpec('uuidv7', options);\nexport const uuidv4 = (options?: IdGeneratorOptionsById['uuidv4']) =>\n createGeneratedSpec('uuidv4', options);\nexport const cuid2 = (options?: IdGeneratorOptionsById['cuid2']) =>\n createGeneratedSpec('cuid2', options);\nexport const ksuid = (options?: IdGeneratorOptionsById['ksuid']) =>\n createGenerated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AAC,aAAa,aAAa;EAC/C,2BAA2B;GACzB,MAAM;IAAE,SAAS;IAAc,YAAY;IAAa;GACxD,YAAY,EAAE,QAAQ,IAAI;GAC3B;EACF;CACF;AAED,MAAaA,mCAGR,oBAAoB,KAAK,QAAQ;CACpC;CACA,oBAAoB,6BAA6B,IAAI;CACtD,EAAE;AAEH,SAAgB,wCAAwC,OAG1B;CAC5B,MAAMC,WAAqC,6BAA6B,MAAM;AAC9E,KAAI,SAAS,iCACX,QAAO,SAAS,iCAAiC,MAAM,OAAO;AAEhE,QAAO,SAAS;;AAalB,SAAS,oBACP,IACA,SAC4C;CAC5C,MAAM,SAAS;CACf,MAAM,qBAAqB,wCAAwC;EACjE;EACA,GAAG,UAAU,UAAU,OAAO;EAC/B,CAAC;AACF,QAAO;EACL,MAAM,mBAAmB;EACzB,UAAU;EACV,GAAG,UAAU,cAAc,mBAAmB,WAAW;EACzD,WAAW;GACT,MAAM;GACN;GACA,GAAG,UAAU,UAAU,OAAO;GAC/B;EACF;;AAGH,MAAa,QAAQ,YACnB,oBAAoB,QAAQ,QAAQ;AACtC,MAAa,UAAU,YACrB,oBAAoB,UAAU,QAAQ;AACxC,MAAa,UAAU,YACrB,oBAAoB,UAAU,QAAQ;AACxC,MAAa,UAAU,YACrB,oBAAoB,UAAU,QAAQ;AACxC,MAAa,SAAS,YACpB,oBAAoB,SAAS,QAAQ;AACvC,MAAa,SAAS,YACpB,oBAAoB,SAAS,QAAQ"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/generator-ids.ts","../src/index.ts"],"sourcesContent":["export const builtinGeneratorIds = [\n 'ulid',\n 'nanoid',\n 'uuidv7',\n 'uuidv4',\n 'cuid2',\n 'ksuid',\n] as const;\n\nexport type BuiltinGeneratorId = (typeof builtinGeneratorIds)[number];\n","import type { ExecutionMutationDefaultValue } from '@prisma-next/contract/types';\nimport type { ColumnTypeDescriptor } from '@prisma-next/framework-components/codec';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { type BuiltinGeneratorId, builtinGeneratorIds } from './generator-ids';\nimport type { IdGeneratorOptionsById } from './generators';\n\nexport { builtinGeneratorIds };\n\nexport type GeneratedColumnDescriptor = {\n readonly type: ColumnTypeDescriptor;\n readonly typeParams?: Record<string, unknown>;\n};\n\ntype BuiltinGeneratorMetadata = {\n readonly applicableCodecIds: readonly string[];\n readonly generatedColumnDescriptor: GeneratedColumnDescriptor;\n readonly resolveGeneratedColumnDescriptor?: (\n params?: Record<string, unknown>,\n ) => GeneratedColumnDescriptor;\n};\n\nfunction resolveNanoidColumnDescriptor(\n params?: Record<string, unknown>,\n): GeneratedColumnDescriptor {\n const rawSize = params?.['size'];\n if (rawSize === undefined) {\n return {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 21 },\n };\n }\n\n if (typeof rawSize !== 'number' || !Number.isInteger(rawSize) || rawSize < 2 || rawSize > 255) {\n throw new Error('nanoid size must be an integer between 2 and 255');\n }\n\n return {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: rawSize },\n };\n}\n\nconst builtinGeneratorMetadataById = {\n ulid: {\n applicableCodecIds: ['pg/text@1', 'sql/char@1'],\n generatedColumnDescriptor: {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 26 },\n },\n },\n nanoid: {\n applicableCodecIds: ['pg/text@1', 'sql/char@1'],\n generatedColumnDescriptor: {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 21 },\n },\n resolveGeneratedColumnDescriptor: resolveNanoidColumnDescriptor,\n },\n uuidv7: {\n applicableCodecIds: ['pg/text@1', 'sql/char@1'],\n generatedColumnDescriptor: {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 36 },\n },\n },\n uuidv4: {\n applicableCodecIds: ['pg/text@1', 'sql/char@1'],\n generatedColumnDescriptor: {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 36 },\n },\n },\n cuid2: {\n applicableCodecIds: ['pg/text@1', 'sql/char@1'],\n generatedColumnDescriptor: {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 24 },\n },\n },\n ksuid: {\n applicableCodecIds: ['pg/text@1', 'sql/char@1'],\n generatedColumnDescriptor: {\n type: { codecId: 'sql/char@1', nativeType: 'character' },\n typeParams: { length: 27 },\n },\n },\n} as const satisfies Record<BuiltinGeneratorId, BuiltinGeneratorMetadata>;\n\nexport const builtinGeneratorRegistryMetadata: ReadonlyArray<{\n readonly id: BuiltinGeneratorId;\n readonly applicableCodecIds: readonly string[];\n}> = builtinGeneratorIds.map((id) => ({\n id,\n applicableCodecIds: builtinGeneratorMetadataById[id].applicableCodecIds,\n}));\n\nexport function resolveBuiltinGeneratedColumnDescriptor(input: {\n readonly id: BuiltinGeneratorId;\n readonly params?: Record<string, unknown>;\n}): GeneratedColumnDescriptor {\n const metadata: BuiltinGeneratorMetadata = builtinGeneratorMetadataById[input.id];\n if (metadata.resolveGeneratedColumnDescriptor) {\n return metadata.resolveGeneratedColumnDescriptor(input.params);\n }\n return metadata.generatedColumnDescriptor;\n}\n\nexport type GeneratedColumnSpec<TCodecId extends string = string> = {\n readonly type: ColumnTypeDescriptor<TCodecId>;\n readonly nullable?: false;\n readonly typeParams?: Record<string, unknown>;\n readonly generated: ExecutionMutationDefaultValue;\n};\n\ntype GeneratorCodecId<TId extends BuiltinGeneratorId> =\n (typeof builtinGeneratorMetadataById)[TId]['generatedColumnDescriptor']['type']['codecId'];\n\nfunction createGeneratedSpec<TId extends BuiltinGeneratorId>(\n id: TId,\n options?: IdGeneratorOptionsById[TId],\n): GeneratedColumnSpec<GeneratorCodecId<TId>> {\n const params = options as Record<string, unknown> | undefined;\n const resolvedDescriptor = resolveBuiltinGeneratedColumnDescriptor({\n id,\n ...ifDefined('params', params),\n });\n return {\n type: resolvedDescriptor.type,\n nullable: false,\n ...ifDefined('typeParams', resolvedDescriptor.typeParams),\n generated: {\n kind: 'generator',\n id,\n ...ifDefined('params', params),\n },\n } as GeneratedColumnSpec<GeneratorCodecId<TId>>;\n}\n\nexport const ulid = (options?: IdGeneratorOptionsById['ulid']) =>\n createGeneratedSpec('ulid', options);\nexport const nanoid = (options?: IdGeneratorOptionsById['nanoid']) =>\n createGeneratedSpec('nanoid', options);\nexport const uuidv7 = (options?: IdGeneratorOptionsById['uuidv7']) =>\n createGeneratedSpec('uuidv7', options);\nexport const uuidv4 = (options?: IdGeneratorOptionsById['uuidv4']) =>\n createGeneratedSpec('uuidv4', options);\nexport const cuid2 = (options?: IdGeneratorOptionsById['cuid2']) =>\n createGeneratedSpec('cuid2', options);\nexport const ksuid = (options?: IdGeneratorOptionsById['ksuid']) =>\n createGeneratedSpec('ksuid', options);\n"],"mappings":";;AAAA,MAAa,sBAAsB;CACjC;CACA;CACA;CACA;CACA;CACA;CACD;;;ACcD,SAAS,8BACP,QAC2B;CAC3B,MAAM,UAAU,SAAS;CACzB,IAAI,YAAY,KAAA,GACd,OAAO;EACL,MAAM;GAAE,SAAS;GAAc,YAAY;GAAa;EACxD,YAAY,EAAE,QAAQ,IAAI;EAC3B;CAGH,IAAI,OAAO,YAAY,YAAY,CAAC,OAAO,UAAU,QAAQ,IAAI,UAAU,KAAK,UAAU,KACxF,MAAM,IAAI,MAAM,mDAAmD;CAGrE,OAAO;EACL,MAAM;GAAE,SAAS;GAAc,YAAY;GAAa;EACxD,YAAY,EAAE,QAAQ,SAAS;EAChC;;AAGH,MAAM,+BAA+B;CACnC,MAAM;EACJ,oBAAoB,CAAC,aAAa,aAAa;EAC/C,2BAA2B;GACzB,MAAM;IAAE,SAAS;IAAc,YAAY;IAAa;GACxD,YAAY,EAAE,QAAQ,IAAI;GAC3B;EACF;CACD,QAAQ;EACN,oBAAoB,CAAC,aAAa,aAAa;EAC/C,2BAA2B;GACzB,MAAM;IAAE,SAAS;IAAc,YAAY;IAAa;GACxD,YAAY,EAAE,QAAQ,IAAI;GAC3B;EACD,kCAAkC;EACnC;CACD,QAAQ;E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oBAAoB,UAAU,QAAQ;AACxC,MAAa,SAAS,YACpB,oBAAoB,SAAS,QAAQ;AACvC,MAAa,SAAS,YACpB,oBAAoB,SAAS,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/runtime.ts"],"sourcesContent":[],"mappings":";;;iBAQgB,UAAA,OAAiB"}
1
+ {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/runtime.ts"],"mappings":";;;iBAQgB,UAAA,CAAW,IAAA,EAAM,kBAAA"}
package/dist/runtime.mjs CHANGED
@@ -4,7 +4,6 @@ import { nanoid } from "uniku/nanoid";
4
4
  import { ulid } from "uniku/ulid";
5
5
  import { uuidv4 } from "uniku/uuid/v4";
6
6
  import { uuidv7 } from "uniku/uuid/v7";
7
-
8
7
  //#region src/generators.ts
9
8
  function invokeGenerator(generator, params) {
10
9
  if (params === void 0) return generator();
@@ -18,7 +17,6 @@ const idGenerators = {
18
17
  cuid2: (params) => invokeGenerator(cuid2, params),
19
18
  ksuid: (params) => invokeGenerator(ksuid, params)
20
19
  };
21
-
22
20
  //#endregion
23
21
  //#region src/runtime.ts
24
22
  function isBuiltinGeneratorId(id) {
@@ -28,7 +26,7 @@ function generateId(spec) {
28
26
  if (!isBuiltinGeneratorId(spec.id)) throw new Error(`Unknown built-in ID generator "${spec.id}".`);
29
27
  return idGenerators[spec.id](spec.params);
30
28
  }
31
-
32
29
  //#endregion
33
30
  export { generateId };
31
+
34
32
  //# sourceMappingURL=runtime.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":["ulidGenerator","nanoidGenerator","uuidv7Generator","uuidv4Generator","cuid2Generator","ksuidGenerator"],"sources":["../src/generators.ts","../src/runtime.ts"],"sourcesContent":["import { cuid2 as cuid2Generator } from 'uniku/cuid2';\nimport { ksuid as ksuidGenerator } from 'uniku/ksuid';\nimport { nanoid as nanoidGenerator } from 'uniku/nanoid';\nimport { ulid as ulidGenerator } from 'uniku/ulid';\nimport { uuidv4 as uuidv4Generator } from 'uniku/uuid/v4';\nimport { uuidv7 as uuidv7Generator } from 'uniku/uuid/v7';\nimport type { BuiltinGeneratorId } from './generator-ids';\n\ntype FirstArg<TFunction> = TFunction extends (...args: infer TArgs) => unknown\n ? TArgs extends []\n ? undefined\n : TArgs[0]\n : never;\n\nexport type IdGeneratorOptionsById = {\n readonly ulid: FirstArg<typeof ulidGenerator>;\n readonly nanoid: FirstArg<typeof nanoidGenerator>;\n readonly uuidv7: FirstArg<typeof uuidv7Generator>;\n readonly uuidv4: FirstArg<typeof uuidv4Generator>;\n readonly cuid2: FirstArg<typeof cuid2Generator>;\n readonly ksuid: FirstArg<typeof ksuidGenerator>;\n};\n\ntype IdGenerator = (params?: Record<string, unknown>) => string;\n\nfunction invokeGenerator<TOptions>(\n generator: (options?: TOptions) => string,\n params?: Record<string, unknown>,\n): string {\n if (params === undefined) {\n return generator();\n }\n return generator(params as TOptions);\n}\n\nexport const idGenerators = {\n ulid: (params?: Record<string, unknown>) => invokeGenerator(ulidGenerator, params),\n nanoid: (params?: Record<string, unknown>) => invokeGenerator(nanoidGenerator, params),\n uuidv7: (params?: Record<string, unknown>) => invokeGenerator(uuidv7Generator, params),\n uuidv4: (params?: Record<string, unknown>) => invokeGenerator(uuidv4Generator, params),\n cuid2: (params?: Record<string, unknown>) => invokeGenerator(cuid2Generator, params),\n ksuid: (params?: Record<string, unknown>) => invokeGenerator(ksuidGenerator, params),\n} as const satisfies Record<BuiltinGeneratorId, IdGenerator>;\n","import type { GeneratedValueSpec } from '@prisma-next/contract/types';\nimport type { BuiltinGeneratorId } from './generator-ids';\nimport { idGenerators } from './generators';\n\nfunction isBuiltinGeneratorId(id: string): id is BuiltinGeneratorId {\n return Object.hasOwn(idGenerators, id);\n}\n\nexport function generateId(spec: GeneratedValueSpec): string {\n if (!isBuiltinGeneratorId(spec.id)) {\n throw new Error(`Unknown built-in ID generator \"${spec.id}\".`);\n }\n return idGenerators[spec.id](spec.params);\n}\n"],"mappings":";;;;;;;;AAyBA,SAAS,gBACP,WACA,QACQ;AACR,KAAI,WAAW,OACb,QAAO,WAAW;AAEpB,QAAO,UAAU,OAAmB;;AAGtC,MAAa,eAAe;CAC1B,OAAO,WAAqC,gBAAgBA,MAAe,OAAO;CAClF,SAAS,WAAqC,gBAAgBC,QAAiB,OAAO;CACtF,SAAS,WAAqC,gBAAgBC,QAAiB,OAAO;CACtF,SAAS,WAAqC,gBAAgBC,QAAiB,OAAO;CACtF,QAAQ,WAAqC,gBAAgBC,OAAgB,OAAO;CACpF,QAAQ,WAAqC,gBAAgBC,OAAgB,OAAO;CACrF;;;;ACtCD,SAAS,qBAAqB,IAAsC;AAClE,QAAO,OAAO,OAAO,cAAc,GAAG;;AAGxC,SAAgB,WAAW,MAAkC;AAC3D,KAAI,CAAC,qBAAqB,KAAK,GAAG,CAChC,OAAM,IAAI,MAAM,kCAAkC,KAAK,GAAG,IAAI;AAEhE,QAAO,aAAa,KAAK,IAAI,KAAK,OAAO"}
1
+ {"version":3,"file":"runtime.mjs","names":["ulidGenerator","nanoidGenerator","uuidv7Generator","uuidv4Generator","cuid2Generator","ksuidGenerator"],"sources":["../src/generators.ts","../src/runtime.ts"],"sourcesContent":["import { cuid2 as cuid2Generator } from 'uniku/cuid2';\nimport { ksuid as ksuidGenerator } from 'uniku/ksuid';\nimport { nanoid as nanoidGenerator } from 'uniku/nanoid';\nimport { ulid as ulidGenerator } from 'uniku/ulid';\nimport { uuidv4 as uuidv4Generator } from 'uniku/uuid/v4';\nimport { uuidv7 as uuidv7Generator } from 'uniku/uuid/v7';\nimport type { BuiltinGeneratorId } from './generator-ids';\n\ntype FirstArg<TFunction> = TFunction extends (...args: infer TArgs) => unknown\n ? TArgs extends []\n ? undefined\n : TArgs[0]\n : never;\n\nexport type IdGeneratorOptionsById = {\n readonly ulid: FirstArg<typeof ulidGenerator>;\n readonly nanoid: FirstArg<typeof nanoidGenerator>;\n readonly uuidv7: FirstArg<typeof uuidv7Generator>;\n readonly uuidv4: FirstArg<typeof uuidv4Generator>;\n readonly cuid2: FirstArg<typeof cuid2Generator>;\n readonly ksuid: FirstArg<typeof ksuidGenerator>;\n};\n\ntype IdGenerator = (params?: Record<string, unknown>) => string;\n\nfunction invokeGenerator<TOptions>(\n generator: (options?: TOptions) => string,\n params?: Record<string, unknown>,\n): string {\n if (params === undefined) {\n return generator();\n }\n return generator(params as TOptions);\n}\n\nexport const idGenerators = {\n ulid: (params?: Record<string, unknown>) => invokeGenerator(ulidGenerator, params),\n nanoid: (params?: Record<string, unknown>) => invokeGenerator(nanoidGenerator, params),\n uuidv7: (params?: Record<string, unknown>) => invokeGenerator(uuidv7Generator, params),\n uuidv4: (params?: Record<string, unknown>) => invokeGenerator(uuidv4Generator, params),\n cuid2: (params?: Record<string, unknown>) => invokeGenerator(cuid2Generator, params),\n ksuid: (params?: Record<string, unknown>) => invokeGenerator(ksuidGenerator, params),\n} as const satisfies Record<BuiltinGeneratorId, IdGenerator>;\n","import type { GeneratedValueSpec } from '@prisma-next/contract/types';\nimport type { BuiltinGeneratorId } from './generator-ids';\nimport { idGenerators } from './generators';\n\nfunction isBuiltinGeneratorId(id: string): id is BuiltinGeneratorId {\n return Object.hasOwn(idGenerators, id);\n}\n\nexport function generateId(spec: GeneratedValueSpec): string {\n if (!isBuiltinGeneratorId(spec.id)) {\n throw new Error(`Unknown built-in ID generator \"${spec.id}\".`);\n }\n return idGenerators[spec.id](spec.params);\n}\n"],"mappings":";;;;;;;AAyBA,SAAS,gBACP,WACA,QACQ;CACR,IAAI,WAAW,KAAA,GACb,OAAO,WAAW;CAEpB,OAAO,UAAU,OAAmB;;AAGtC,MAAa,eAAe;CAC1B,OAAO,WAAqC,gBAAgBA,MAAe,OAAO;CAClF,SAAS,WAAqC,gBAAgBC,QAAiB,OAAO;CACtF,SAAS,WAAqC,gBAAgBC,QAAiB,OAAO;CACtF,SAAS,WAAqC,gBAAgBC,QAAiB,OAAO;CACtF,QAAQ,WAAqC,gBAAgBC,OAAgB,OAAO;CACpF,QAAQ,WAAqC,gBAAgBC,OAAgB,OAAO;CACrF;;;ACtCD,SAAS,qBAAqB,IAAsC;CAClE,OAAO,OAAO,OAAO,cAAc,GAAG;;AAGxC,SAAgB,WAAW,MAAkC;CAC3D,IAAI,CAAC,qBAAqB,KAAK,GAAG,EAChC,MAAM,IAAI,MAAM,kCAAkC,KAAK,GAAG,IAAI;CAEhE,OAAO,aAAa,KAAK,IAAI,KAAK,OAAO"}
package/package.json CHANGED
@@ -1,21 +1,22 @@
1
1
  {
2
2
  "name": "@prisma-next/ids",
3
- "version": "0.5.0-dev.9",
3
+ "version": "0.5.0",
4
+ "license": "Apache-2.0",
4
5
  "type": "module",
5
6
  "sideEffects": false,
6
7
  "description": "ID generator helpers for Prisma Next contracts",
7
8
  "dependencies": {
8
9
  "uniku": "^0.0.12",
9
- "@prisma-next/contract": "0.5.0-dev.9",
10
- "@prisma-next/utils": "0.5.0-dev.9",
11
- "@prisma-next/contract-authoring": "0.5.0-dev.9"
10
+ "@prisma-next/contract": "0.5.0",
11
+ "@prisma-next/framework-components": "0.5.0",
12
+ "@prisma-next/utils": "0.5.0"
12
13
  },
13
14
  "devDependencies": {
14
- "tsdown": "0.18.4",
15
+ "tsdown": "0.22.0",
15
16
  "typescript": "5.9.3",
16
- "vitest": "4.0.17",
17
- "@prisma-next/tsconfig": "0.0.0",
18
- "@prisma-next/tsdown": "0.0.0"
17
+ "vitest": "4.1.5",
18
+ "@prisma-next/tsdown": "0.0.0",
19
+ "@prisma-next/tsconfig": "0.0.0"
19
20
  },
20
21
  "files": [
21
22
  "dist",
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ExecutionMutationDefaultValue } from '@prisma-next/contract/types';
2
- import type { ColumnTypeDescriptor } from '@prisma-next/contract-authoring';
2
+ import type { ColumnTypeDescriptor } from '@prisma-next/framework-components/codec';
3
3
  import { ifDefined } from '@prisma-next/utils/defined';
4
4
  import { type BuiltinGeneratorId, builtinGeneratorIds } from './generator-ids';
5
5
  import type { IdGeneratorOptionsById } from './generators';