@prisma-next/contract 0.3.0-pr.99.5 → 0.3.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.
Files changed (58) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +43 -254
  3. package/dist/contract-types-MYdoYIIh.d.mts +314 -0
  4. package/dist/contract-types-MYdoYIIh.d.mts.map +1 -0
  5. package/dist/hashing-CyaA_Qvf.mjs +196 -0
  6. package/dist/hashing-CyaA_Qvf.mjs.map +1 -0
  7. package/dist/hashing.d.mts +29 -0
  8. package/dist/hashing.d.mts.map +1 -0
  9. package/dist/hashing.mjs +3 -0
  10. package/dist/testing.d.mts +29 -0
  11. package/dist/testing.d.mts.map +1 -0
  12. package/dist/testing.mjs +58 -0
  13. package/dist/testing.mjs.map +1 -0
  14. package/dist/types-aMyNgejf.mjs +14 -0
  15. package/dist/types-aMyNgejf.mjs.map +1 -0
  16. package/dist/types.d.mts +2 -2
  17. package/dist/types.mjs +2 -10
  18. package/dist/validate-contract.d.mts +37 -0
  19. package/dist/validate-contract.d.mts.map +1 -0
  20. package/dist/validate-contract.mjs +3 -0
  21. package/dist/validate-domain-CpCcTlqJ.mjs +165 -0
  22. package/dist/validate-domain-CpCcTlqJ.mjs.map +1 -0
  23. package/dist/validate-domain.d.mts +24 -0
  24. package/dist/validate-domain.d.mts.map +1 -0
  25. package/dist/validate-domain.mjs +3 -0
  26. package/package.json +15 -8
  27. package/schemas/data-contract-document-v1.json +5 -5
  28. package/src/canonicalization.ts +263 -0
  29. package/src/contract-types.ts +55 -0
  30. package/src/domain-types.ts +95 -0
  31. package/src/exports/hashing.ts +2 -0
  32. package/src/exports/testing.ts +1 -0
  33. package/src/exports/types.ts +36 -20
  34. package/src/exports/validate-contract.ts +6 -0
  35. package/src/exports/validate-domain.ts +5 -0
  36. package/src/hashing.ts +53 -0
  37. package/src/testing-factories.ts +101 -0
  38. package/src/types.ts +102 -248
  39. package/src/validate-contract.ts +101 -0
  40. package/src/validate-domain.ts +227 -0
  41. package/dist/framework-components-B-XOtXw3.d.mts +0 -854
  42. package/dist/framework-components-B-XOtXw3.d.mts.map +0 -1
  43. package/dist/framework-components.d.mts +0 -2
  44. package/dist/framework-components.mjs +0 -70
  45. package/dist/framework-components.mjs.map +0 -1
  46. package/dist/ir-B8zNqals.d.mts +0 -79
  47. package/dist/ir-B8zNqals.d.mts.map +0 -1
  48. package/dist/ir.d.mts +0 -2
  49. package/dist/ir.mjs +0 -46
  50. package/dist/ir.mjs.map +0 -1
  51. package/dist/pack-manifest-types.d.mts +0 -2
  52. package/dist/pack-manifest-types.mjs +0 -1
  53. package/dist/types.mjs.map +0 -1
  54. package/src/exports/framework-components.ts +0 -36
  55. package/src/exports/ir.ts +0 -1
  56. package/src/exports/pack-manifest-types.ts +0 -6
  57. package/src/framework-components.ts +0 -717
  58. package/src/ir.ts +0 -113
package/src/ir.ts DELETED
@@ -1,113 +0,0 @@
1
- /**
2
- * ContractIR types and factories for building contract intermediate representation.
3
- * ContractIR is family-agnostic and used by authoring, emitter, and no-emit runtime.
4
- */
5
-
6
- /**
7
- * ContractIR represents the intermediate representation of a contract.
8
- * It is family-agnostic and contains generic storage, models, and relations.
9
- * Note: coreHash and profileHash are computed by the emitter, not part of the IR.
10
- */
11
- export interface ContractIR<
12
- TStorage extends Record<string, unknown> = Record<string, unknown>,
13
- TModels extends Record<string, unknown> = Record<string, unknown>,
14
- TRelations extends Record<string, unknown> = Record<string, unknown>,
15
- > {
16
- readonly schemaVersion: string;
17
- readonly targetFamily: string;
18
- readonly target: string;
19
- readonly models: TModels;
20
- readonly relations: TRelations;
21
- readonly storage: TStorage;
22
- readonly extensionPacks: Record<string, unknown>;
23
- readonly capabilities: Record<string, Record<string, boolean>>;
24
- readonly meta: Record<string, unknown>;
25
- readonly sources: Record<string, unknown>;
26
- }
27
-
28
- /**
29
- * Creates the header portion of a ContractIR.
30
- * Contains schema version, target, target family, core hash, and optional profile hash.
31
- */
32
- export function irHeader(opts: {
33
- target: string;
34
- targetFamily: string;
35
- coreHash: string;
36
- profileHash?: string | undefined;
37
- }): {
38
- readonly schemaVersion: string;
39
- readonly target: string;
40
- readonly targetFamily: string;
41
- readonly coreHash: string;
42
- readonly profileHash?: string | undefined;
43
- } {
44
- return {
45
- schemaVersion: '1',
46
- target: opts.target,
47
- targetFamily: opts.targetFamily,
48
- coreHash: opts.coreHash,
49
- ...(opts.profileHash !== undefined && { profileHash: opts.profileHash }),
50
- };
51
- }
52
-
53
- /**
54
- * Creates the meta portion of a ContractIR.
55
- * Contains capabilities, extensionPacks, meta, and sources with empty object defaults.
56
- * If a field is explicitly `undefined`, it will be omitted (for testing validation).
57
- */
58
- export function irMeta(opts?: {
59
- capabilities?: Record<string, Record<string, boolean>> | undefined;
60
- extensionPacks?: Record<string, unknown> | undefined;
61
- meta?: Record<string, unknown> | undefined;
62
- sources?: Record<string, unknown> | undefined;
63
- }): {
64
- readonly capabilities: Record<string, Record<string, boolean>>;
65
- readonly extensionPacks: Record<string, unknown>;
66
- readonly meta: Record<string, unknown>;
67
- readonly sources: Record<string, unknown>;
68
- } {
69
- return {
70
- capabilities: opts?.capabilities ?? {},
71
- extensionPacks: opts?.extensionPacks ?? {},
72
- meta: opts?.meta ?? {},
73
- sources: opts?.sources ?? {},
74
- };
75
- }
76
-
77
- /**
78
- * Creates a complete ContractIR by combining header, meta, and family-specific sections.
79
- * This is a family-agnostic factory that accepts generic storage, models, and relations.
80
- */
81
- export function contractIR<
82
- TStorage extends Record<string, unknown>,
83
- TModels extends Record<string, unknown>,
84
- TRelations extends Record<string, unknown>,
85
- >(opts: {
86
- header: {
87
- readonly schemaVersion: string;
88
- readonly target: string;
89
- readonly targetFamily: string;
90
- readonly coreHash: string;
91
- readonly profileHash?: string | undefined;
92
- };
93
- meta: {
94
- readonly capabilities: Record<string, Record<string, boolean>>;
95
- readonly extensionPacks: Record<string, unknown>;
96
- readonly meta: Record<string, unknown>;
97
- readonly sources: Record<string, unknown>;
98
- };
99
- storage: TStorage;
100
- models: TModels;
101
- relations: TRelations;
102
- }): ContractIR<TStorage, TModels, TRelations> {
103
- // ContractIR doesn't include coreHash or profileHash (those are computed by emitter)
104
- return {
105
- schemaVersion: opts.header.schemaVersion,
106
- target: opts.header.target,
107
- targetFamily: opts.header.targetFamily,
108
- ...opts.meta,
109
- storage: opts.storage,
110
- models: opts.models,
111
- relations: opts.relations,
112
- };
113
- }