@xemahq/contracts 0.32.0 → 0.34.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 (126) hide show
  1. package/dist/.source-stamp.json +2 -2
  2. package/dist/authorization-facts/index.d.ts +6 -0
  3. package/dist/authorization-facts/index.d.ts.map +1 -0
  4. package/dist/authorization-facts/index.js +22 -0
  5. package/dist/authorization-facts/index.js.map +1 -0
  6. package/dist/authorization-facts/lib/fact-tuple.d.ts +38 -0
  7. package/dist/authorization-facts/lib/fact-tuple.d.ts.map +1 -0
  8. package/dist/authorization-facts/lib/fact-tuple.js +48 -0
  9. package/dist/authorization-facts/lib/fact-tuple.js.map +1 -0
  10. package/dist/authorization-facts/lib/facts-apply.d.ts +244 -0
  11. package/dist/authorization-facts/lib/facts-apply.d.ts.map +1 -0
  12. package/dist/authorization-facts/lib/facts-apply.js +141 -0
  13. package/dist/authorization-facts/lib/facts-apply.js.map +1 -0
  14. package/dist/authorization-facts/lib/facts-snapshot.d.ts +70 -0
  15. package/dist/authorization-facts/lib/facts-snapshot.d.ts.map +1 -0
  16. package/dist/authorization-facts/lib/facts-snapshot.js +39 -0
  17. package/dist/authorization-facts/lib/facts-snapshot.js.map +1 -0
  18. package/dist/authorization-facts/lib/facts-writer-authority.d.ts +15 -0
  19. package/dist/authorization-facts/lib/facts-writer-authority.d.ts.map +1 -0
  20. package/dist/authorization-facts/lib/facts-writer-authority.js +55 -0
  21. package/dist/authorization-facts/lib/facts-writer-authority.js.map +1 -0
  22. package/dist/authorization-facts/lib/revoke-intent.d.ts +23 -0
  23. package/dist/authorization-facts/lib/revoke-intent.d.ts.map +1 -0
  24. package/dist/authorization-facts/lib/revoke-intent.js +37 -0
  25. package/dist/authorization-facts/lib/revoke-intent.js.map +1 -0
  26. package/dist/authorization-module/index.d.ts +6 -0
  27. package/dist/authorization-module/index.d.ts.map +1 -0
  28. package/dist/authorization-module/index.js +22 -0
  29. package/dist/authorization-module/index.js.map +1 -0
  30. package/dist/authorization-module/lib/authorization-composition-error.d.ts +46 -0
  31. package/dist/authorization-module/lib/authorization-composition-error.d.ts.map +1 -0
  32. package/dist/authorization-module/lib/authorization-composition-error.js +53 -0
  33. package/dist/authorization-module/lib/authorization-composition-error.js.map +1 -0
  34. package/dist/authorization-module/lib/authorization-module-contribution.d.ts +143 -0
  35. package/dist/authorization-module/lib/authorization-module-contribution.d.ts.map +1 -0
  36. package/dist/authorization-module/lib/authorization-module-contribution.js +111 -0
  37. package/dist/authorization-module/lib/authorization-module-contribution.js.map +1 -0
  38. package/dist/authorization-module/lib/authorization-module-envelope.d.ts +116 -0
  39. package/dist/authorization-module/lib/authorization-module-envelope.d.ts.map +1 -0
  40. package/dist/authorization-module/lib/authorization-module-envelope.js +104 -0
  41. package/dist/authorization-module/lib/authorization-module-envelope.js.map +1 -0
  42. package/dist/authorization-module/lib/authorization-namespace.d.ts +23 -0
  43. package/dist/authorization-module/lib/authorization-namespace.d.ts.map +1 -0
  44. package/dist/authorization-module/lib/authorization-namespace.js +82 -0
  45. package/dist/authorization-module/lib/authorization-namespace.js.map +1 -0
  46. package/dist/authorization-module/lib/platform-authorization-modules.d.ts +19 -0
  47. package/dist/authorization-module/lib/platform-authorization-modules.d.ts.map +1 -0
  48. package/dist/authorization-module/lib/platform-authorization-modules.js +48 -0
  49. package/dist/authorization-module/lib/platform-authorization-modules.js.map +1 -0
  50. package/dist/authorization-module/platform/xema_capability.fga +23 -0
  51. package/dist/authorization-module/platform/xema_capability.fga.yaml +108 -0
  52. package/dist/authorization-module/platform/xema_core.fga +82 -0
  53. package/dist/authorization-module/platform/xema_core.fga.yaml +123 -0
  54. package/dist/authorization-module/platform/xema_sharing.fga +138 -0
  55. package/dist/authorization-module/platform/xema_sharing.fga.yaml +112 -0
  56. package/dist/authorization-module/server/authorization-compatibility.d.ts +16 -0
  57. package/dist/authorization-module/server/authorization-compatibility.d.ts.map +1 -0
  58. package/dist/authorization-module/server/authorization-compatibility.js +94 -0
  59. package/dist/authorization-module/server/authorization-compatibility.js.map +1 -0
  60. package/dist/authorization-module/server/authorization-model-json.d.ts +65 -0
  61. package/dist/authorization-module/server/authorization-model-json.d.ts.map +1 -0
  62. package/dist/authorization-module/server/authorization-model-json.js +21 -0
  63. package/dist/authorization-module/server/authorization-model-json.js.map +1 -0
  64. package/dist/authorization-module/server/compose-authorization-base.d.ts +67 -0
  65. package/dist/authorization-module/server/compose-authorization-base.d.ts.map +1 -0
  66. package/dist/authorization-module/server/compose-authorization-base.js +520 -0
  67. package/dist/authorization-module/server/compose-authorization-base.js.map +1 -0
  68. package/dist/authorization-module/server/index.d.ts +5 -0
  69. package/dist/authorization-module/server/index.d.ts.map +1 -0
  70. package/dist/authorization-module/server/index.js +21 -0
  71. package/dist/authorization-module/server/index.js.map +1 -0
  72. package/dist/authorization-module/server/platform-module-files.d.ts +16 -0
  73. package/dist/authorization-module/server/platform-module-files.d.ts.map +1 -0
  74. package/dist/authorization-module/server/platform-module-files.js +42 -0
  75. package/dist/authorization-module/server/platform-module-files.js.map +1 -0
  76. package/dist/authzen/index.d.ts +7 -0
  77. package/dist/authzen/index.d.ts.map +1 -0
  78. package/dist/authzen/index.js +23 -0
  79. package/dist/authzen/index.js.map +1 -0
  80. package/dist/authzen/lib/authzen-entities.d.ts +40 -0
  81. package/dist/authzen/lib/authzen-entities.d.ts.map +1 -0
  82. package/dist/authzen/lib/authzen-entities.js +48 -0
  83. package/dist/authzen/lib/authzen-entities.js.map +1 -0
  84. package/dist/authzen/lib/authzen-evaluation.d.ts +101 -0
  85. package/dist/authzen/lib/authzen-evaluation.d.ts.map +1 -0
  86. package/dist/authzen/lib/authzen-evaluation.js +103 -0
  87. package/dist/authzen/lib/authzen-evaluation.js.map +1 -0
  88. package/dist/authzen/lib/authzen-metadata.d.ts +25 -0
  89. package/dist/authzen/lib/authzen-metadata.d.ts.map +1 -0
  90. package/dist/authzen/lib/authzen-metadata.js +54 -0
  91. package/dist/authzen/lib/authzen-metadata.js.map +1 -0
  92. package/dist/authzen/lib/authzen-search.d.ts +135 -0
  93. package/dist/authzen/lib/authzen-search.d.ts.map +1 -0
  94. package/dist/authzen/lib/authzen-search.js +89 -0
  95. package/dist/authzen/lib/authzen-search.js.map +1 -0
  96. package/dist/authzen/lib/authzen-snapshot.d.ts +47 -0
  97. package/dist/authzen/lib/authzen-snapshot.d.ts.map +1 -0
  98. package/dist/authzen/lib/authzen-snapshot.js +96 -0
  99. package/dist/authzen/lib/authzen-snapshot.js.map +1 -0
  100. package/dist/authzen/lib/xema-authzen-profile.d.ts +155 -0
  101. package/dist/authzen/lib/xema-authzen-profile.d.ts.map +1 -0
  102. package/dist/authzen/lib/xema-authzen-profile.js +152 -0
  103. package/dist/authzen/lib/xema-authzen-profile.js.map +1 -0
  104. package/dist/biome/lib/biome-generated-index.d.ts +1 -0
  105. package/dist/biome/lib/biome-generated-index.d.ts.map +1 -1
  106. package/dist/biome/lib/biome-generated-index.js +2 -0
  107. package/dist/biome/lib/biome-generated-index.js.map +1 -1
  108. package/dist/contribution/lib/contribution-kind.d.ts +1 -0
  109. package/dist/contribution/lib/contribution-kind.d.ts.map +1 -1
  110. package/dist/contribution/lib/contribution-kind.js +1 -0
  111. package/dist/contribution/lib/contribution-kind.js.map +1 -1
  112. package/dist/platform-generation/index.d.ts +2 -0
  113. package/dist/platform-generation/index.d.ts.map +1 -0
  114. package/dist/platform-generation/index.js +18 -0
  115. package/dist/platform-generation/index.js.map +1 -0
  116. package/dist/platform-generation/lib/platform-generation.d.ts +20 -0
  117. package/dist/platform-generation/lib/platform-generation.d.ts.map +1 -0
  118. package/dist/platform-generation/lib/platform-generation.js +77 -0
  119. package/dist/platform-generation/lib/platform-generation.js.map +1 -0
  120. package/dist/resource/lib/resource-kind-descriptor.d.ts.map +1 -1
  121. package/dist/resource/lib/resource-kind-descriptor.js.map +1 -1
  122. package/dist/resource/lib/resource-kind-registry.d.ts.map +1 -1
  123. package/dist/resource/lib/resource-kind-registry.js.map +1 -1
  124. package/dist/resource/lib/resource-ownership-contribution.d.ts.map +1 -1
  125. package/dist/resource/lib/resource-ownership-contribution.js.map +1 -1
  126. package/package.json +6 -4
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "algorithm": "sha256/len-framed-v1",
3
- "hash": "5a1e141a1c477a0bf74a5ddf1c297083f7e78d2cd331d1387c3ee5163bd9ea46",
4
- "fileCount": 540
3
+ "hash": "028bc8324a4e7af8a25559b754a47d1469c8ebf1e7c47026cf803d70644bdeb1",
4
+ "fileCount": 572
5
5
  }
@@ -0,0 +1,6 @@
1
+ export * from './lib/fact-tuple';
2
+ export * from './lib/facts-apply';
3
+ export * from './lib/facts-writer-authority';
4
+ export * from './lib/revoke-intent';
5
+ export * from './lib/facts-snapshot';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authorization-facts/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./lib/fact-tuple"), exports);
18
+ __exportStar(require("./lib/facts-apply"), exports);
19
+ __exportStar(require("./lib/facts-writer-authority"), exports);
20
+ __exportStar(require("./lib/revoke-intent"), exports);
21
+ __exportStar(require("./lib/facts-snapshot"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/authorization-facts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,oDAAkC;AAClC,+DAA6C;AAC7C,sDAAoC;AACpC,uDAAqC"}
@@ -0,0 +1,38 @@
1
+ import { z } from 'zod';
2
+ export declare const FACT_TYPE_PATTERN: RegExp;
3
+ export declare const FACT_RELATION_PATTERN: RegExp;
4
+ export declare const FACT_OBJECT_ID_PATTERN: RegExp;
5
+ export declare const FactTypeSchema: z.ZodString;
6
+ export declare const FactRelationSchema: z.ZodString;
7
+ export declare const FactObjectRefSchema: z.ZodObject<{
8
+ type: z.ZodString;
9
+ id: z.ZodString;
10
+ }, z.core.$strict>;
11
+ export type FactObjectRef = z.infer<typeof FactObjectRefSchema>;
12
+ export declare const FACT_WILDCARD_SUBJECT_ID = "*";
13
+ export declare const FactSubjectRefSchema: z.ZodObject<{
14
+ type: z.ZodString;
15
+ id: z.ZodString;
16
+ relation: z.ZodOptional<z.ZodString>;
17
+ }, z.core.$strict>;
18
+ export type FactSubjectRef = z.infer<typeof FactSubjectRefSchema>;
19
+ export declare const FactConditionSchema: z.ZodObject<{
20
+ name: z.ZodString;
21
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
22
+ }, z.core.$strict>;
23
+ export type FactCondition = z.infer<typeof FactConditionSchema>;
24
+ export declare const FactTupleSchema: z.ZodObject<{
25
+ relation: z.ZodString;
26
+ subject: z.ZodObject<{
27
+ type: z.ZodString;
28
+ id: z.ZodString;
29
+ relation: z.ZodOptional<z.ZodString>;
30
+ }, z.core.$strict>;
31
+ condition: z.ZodOptional<z.ZodObject<{
32
+ name: z.ZodString;
33
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
34
+ }, z.core.$strict>>;
35
+ }, z.core.$strict>;
36
+ export type FactTuple = z.infer<typeof FactTupleSchema>;
37
+ export declare function factTupleKey(object: FactObjectRef, tuple: FactTuple): string;
38
+ //# sourceMappingURL=fact-tuple.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fact-tuple.d.ts","sourceRoot":"","sources":["../../../src/authorization-facts/lib/fact-tuple.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBxB,eAAO,MAAM,iBAAiB,QAAuB,CAAC;AAEtD,eAAO,MAAM,qBAAqB,QAAsB,CAAC;AAEzD,eAAO,MAAM,sBAAsB,QAA6B,CAAC;AAEjE,eAAO,MAAM,cAAc,aAAsC,CAAC;AAClE,eAAO,MAAM,kBAAkB,aAA0C,CAAC;AAG1E,eAAO,MAAM,mBAAmB;;;kBAOrB,CAAC;AACZ,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAGhE,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAQ5C,eAAO,MAAM,oBAAoB;;;;kBAW9B,CAAC;AACJ,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAGlE,eAAO,MAAM,mBAAmB;;;kBAKrB,CAAC;AACZ,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAGhE,eAAO,MAAM,eAAe;;;;;;;;;;;kBAMjB,CAAC;AACZ,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAGxD,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,GAAG,MAAM,CAM5E"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FactTupleSchema = exports.FactConditionSchema = exports.FactSubjectRefSchema = exports.FACT_WILDCARD_SUBJECT_ID = exports.FactObjectRefSchema = exports.FactRelationSchema = exports.FactTypeSchema = exports.FACT_OBJECT_ID_PATTERN = exports.FACT_RELATION_PATTERN = exports.FACT_TYPE_PATTERN = void 0;
4
+ exports.factTupleKey = factTupleKey;
5
+ const zod_1 = require("zod");
6
+ const authzen_1 = require("../../authzen");
7
+ exports.FACT_TYPE_PATTERN = /^[^:#@*\s]{1,254}$/;
8
+ exports.FACT_RELATION_PATTERN = /^[^:#@*\s]{1,50}$/;
9
+ exports.FACT_OBJECT_ID_PATTERN = /^[a-zA-Z0-9_|*@.+/\-~]+$/;
10
+ exports.FactTypeSchema = zod_1.z.string().regex(exports.FACT_TYPE_PATTERN);
11
+ exports.FactRelationSchema = zod_1.z.string().regex(exports.FACT_RELATION_PATTERN);
12
+ exports.FactObjectRefSchema = zod_1.z
13
+ .object({
14
+ type: exports.FactTypeSchema,
15
+ id: zod_1.z.string().regex(exports.FACT_OBJECT_ID_PATTERN).refine((id) => id !== '*', {
16
+ message: 'an object id cannot be the wildcard.',
17
+ }),
18
+ })
19
+ .strict();
20
+ exports.FACT_WILDCARD_SUBJECT_ID = '*';
21
+ exports.FactSubjectRefSchema = zod_1.z
22
+ .object({
23
+ type: exports.FactTypeSchema,
24
+ id: zod_1.z.string().regex(exports.FACT_OBJECT_ID_PATTERN),
25
+ relation: exports.FactRelationSchema.optional(),
26
+ })
27
+ .strict()
28
+ .refine((subject) => !(subject.id === exports.FACT_WILDCARD_SUBJECT_ID && subject.relation !== undefined), { message: 'a wildcard subject cannot carry a relation (`user:*#x` is not a subject).' });
29
+ exports.FactConditionSchema = zod_1.z
30
+ .object({
31
+ name: zod_1.z.string().min(1),
32
+ context: authzen_1.AuthzenAttributesSchema.optional(),
33
+ })
34
+ .strict();
35
+ exports.FactTupleSchema = zod_1.z
36
+ .object({
37
+ relation: exports.FactRelationSchema,
38
+ subject: exports.FactSubjectRefSchema,
39
+ condition: exports.FactConditionSchema.optional(),
40
+ })
41
+ .strict();
42
+ function factTupleKey(object, tuple) {
43
+ const subject = tuple.subject.relation === undefined
44
+ ? `${tuple.subject.type}:${tuple.subject.id}`
45
+ : `${tuple.subject.type}:${tuple.subject.id}#${tuple.subject.relation}`;
46
+ return `${object.type}:${object.id}#${tuple.relation}@${subject}`;
47
+ }
48
+ //# sourceMappingURL=fact-tuple.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fact-tuple.js","sourceRoot":"","sources":["../../../src/authorization-facts/lib/fact-tuple.ts"],"names":[],"mappings":";;;AAgFA,oCAMC;AAtFD,6BAAwB;AAExB,2CAAwD;AAe3C,QAAA,iBAAiB,GAAG,oBAAoB,CAAC;AAEzC,QAAA,qBAAqB,GAAG,mBAAmB,CAAC;AAE5C,QAAA,sBAAsB,GAAG,0BAA0B,CAAC;AAEpD,QAAA,cAAc,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,yBAAiB,CAAC,CAAC;AACrD,QAAA,kBAAkB,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,6BAAqB,CAAC,CAAC;AAG7D,QAAA,mBAAmB,GAAG,OAAC;KACjC,MAAM,CAAC;IACN,IAAI,EAAE,sBAAc;IACpB,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,8BAAsB,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,GAAG,EAAE;QACtE,OAAO,EAAE,sCAAsC;KAChD,CAAC;CACH,CAAC;KACD,MAAM,EAAE,CAAC;AAIC,QAAA,wBAAwB,GAAG,GAAG,CAAC;AAQ/B,QAAA,oBAAoB,GAAG,OAAC;KAClC,MAAM,CAAC;IACN,IAAI,EAAE,sBAAc;IACpB,EAAE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export declare const FACTS_APPLY_MAX_TUPLES = 100;
3
+ export declare const FactsVersionSchema: z.ZodNumber;
4
+ export declare enum FactChangeKind {
5
+ Delta = "delta",
6
+ DesiredState = "desired-state",
7
+ DeleteObject = "delete-object"
8
+ }
9
+ export declare const FactChangeKindSchema: z.ZodEnum<typeof FactChangeKind>;
10
+ export declare const DeltaFactChangeSchema: z.ZodObject<{
11
+ kind: z.ZodLiteral<FactChangeKind.Delta>;
12
+ object: z.ZodObject<{
13
+ type: z.ZodString;
14
+ id: z.ZodString;
15
+ }, z.core.$strict>;
16
+ version: z.ZodNumber;
17
+ writes: z.ZodArray<z.ZodObject<{
18
+ relation: z.ZodString;
19
+ subject: z.ZodObject<{
20
+ type: z.ZodString;
21
+ id: z.ZodString;
22
+ relation: z.ZodOptional<z.ZodString>;
23
+ }, z.core.$strict>;
24
+ condition: z.ZodOptional<z.ZodObject<{
25
+ name: z.ZodString;
26
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
27
+ }, z.core.$strict>>;
28
+ }, z.core.$strict>>;
29
+ deletes: z.ZodArray<z.ZodObject<{
30
+ relation: z.ZodString;
31
+ subject: z.ZodObject<{
32
+ type: z.ZodString;
33
+ id: z.ZodString;
34
+ relation: z.ZodOptional<z.ZodString>;
35
+ }, z.core.$strict>;
36
+ condition: z.ZodOptional<z.ZodObject<{
37
+ name: z.ZodString;
38
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
39
+ }, z.core.$strict>>;
40
+ }, z.core.$strict>>;
41
+ revokeIntentId: z.ZodOptional<z.ZodString>;
42
+ }, z.core.$strict>;
43
+ export declare const DesiredFactSubjectSchema: z.ZodObject<{
44
+ subject: z.ZodObject<{
45
+ type: z.ZodString;
46
+ id: z.ZodString;
47
+ relation: z.ZodOptional<z.ZodString>;
48
+ }, z.core.$strict>;
49
+ condition: z.ZodOptional<z.ZodObject<{
50
+ name: z.ZodString;
51
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
52
+ }, z.core.$strict>>;
53
+ }, z.core.$strict>;
54
+ export declare const DesiredStateFactChangeSchema: z.ZodObject<{
55
+ kind: z.ZodLiteral<FactChangeKind.DesiredState>;
56
+ object: z.ZodObject<{
57
+ type: z.ZodString;
58
+ id: z.ZodString;
59
+ }, z.core.$strict>;
60
+ version: z.ZodNumber;
61
+ relations: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
62
+ subject: z.ZodObject<{
63
+ type: z.ZodString;
64
+ id: z.ZodString;
65
+ relation: z.ZodOptional<z.ZodString>;
66
+ }, z.core.$strict>;
67
+ condition: z.ZodOptional<z.ZodObject<{
68
+ name: z.ZodString;
69
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
70
+ }, z.core.$strict>>;
71
+ }, z.core.$strict>>>;
72
+ revokeIntentId: z.ZodOptional<z.ZodString>;
73
+ }, z.core.$strict>;
74
+ export declare const DeleteObjectFactChangeSchema: z.ZodObject<{
75
+ kind: z.ZodLiteral<FactChangeKind.DeleteObject>;
76
+ object: z.ZodObject<{
77
+ type: z.ZodString;
78
+ id: z.ZodString;
79
+ }, z.core.$strict>;
80
+ version: z.ZodNumber;
81
+ }, z.core.$strict>;
82
+ export declare const FactChangeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
83
+ kind: z.ZodLiteral<FactChangeKind.Delta>;
84
+ object: z.ZodObject<{
85
+ type: z.ZodString;
86
+ id: z.ZodString;
87
+ }, z.core.$strict>;
88
+ version: z.ZodNumber;
89
+ writes: z.ZodArray<z.ZodObject<{
90
+ relation: z.ZodString;
91
+ subject: z.ZodObject<{
92
+ type: z.ZodString;
93
+ id: z.ZodString;
94
+ relation: z.ZodOptional<z.ZodString>;
95
+ }, z.core.$strict>;
96
+ condition: z.ZodOptional<z.ZodObject<{
97
+ name: z.ZodString;
98
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
99
+ }, z.core.$strict>>;
100
+ }, z.core.$strict>>;
101
+ deletes: z.ZodArray<z.ZodObject<{
102
+ relation: z.ZodString;
103
+ subject: z.ZodObject<{
104
+ type: z.ZodString;
105
+ id: z.ZodString;
106
+ relation: z.ZodOptional<z.ZodString>;
107
+ }, z.core.$strict>;
108
+ condition: z.ZodOptional<z.ZodObject<{
109
+ name: z.ZodString;
110
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
111
+ }, z.core.$strict>>;
112
+ }, z.core.$strict>>;
113
+ revokeIntentId: z.ZodOptional<z.ZodString>;
114
+ }, z.core.$strict>, z.ZodObject<{
115
+ kind: z.ZodLiteral<FactChangeKind.DesiredState>;
116
+ object: z.ZodObject<{
117
+ type: z.ZodString;
118
+ id: z.ZodString;
119
+ }, z.core.$strict>;
120
+ version: z.ZodNumber;
121
+ relations: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
122
+ subject: z.ZodObject<{
123
+ type: z.ZodString;
124
+ id: z.ZodString;
125
+ relation: z.ZodOptional<z.ZodString>;
126
+ }, z.core.$strict>;
127
+ condition: z.ZodOptional<z.ZodObject<{
128
+ name: z.ZodString;
129
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
130
+ }, z.core.$strict>>;
131
+ }, z.core.$strict>>>;
132
+ revokeIntentId: z.ZodOptional<z.ZodString>;
133
+ }, z.core.$strict>, z.ZodObject<{
134
+ kind: z.ZodLiteral<FactChangeKind.DeleteObject>;
135
+ object: z.ZodObject<{
136
+ type: z.ZodString;
137
+ id: z.ZodString;
138
+ }, z.core.$strict>;
139
+ version: z.ZodNumber;
140
+ }, z.core.$strict>], "kind">;
141
+ export type FactChange = z.infer<typeof FactChangeSchema>;
142
+ export declare function namedTupleCount(change: FactChange): number;
143
+ export declare const FactsApplyRequestSchema: z.ZodObject<{
144
+ orgId: z.ZodString;
145
+ biomeId: z.ZodString;
146
+ changes: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
147
+ kind: z.ZodLiteral<FactChangeKind.Delta>;
148
+ object: z.ZodObject<{
149
+ type: z.ZodString;
150
+ id: z.ZodString;
151
+ }, z.core.$strict>;
152
+ version: z.ZodNumber;
153
+ writes: z.ZodArray<z.ZodObject<{
154
+ relation: z.ZodString;
155
+ subject: z.ZodObject<{
156
+ type: z.ZodString;
157
+ id: z.ZodString;
158
+ relation: z.ZodOptional<z.ZodString>;
159
+ }, z.core.$strict>;
160
+ condition: z.ZodOptional<z.ZodObject<{
161
+ name: z.ZodString;
162
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
163
+ }, z.core.$strict>>;
164
+ }, z.core.$strict>>;
165
+ deletes: z.ZodArray<z.ZodObject<{
166
+ relation: z.ZodString;
167
+ subject: z.ZodObject<{
168
+ type: z.ZodString;
169
+ id: z.ZodString;
170
+ relation: z.ZodOptional<z.ZodString>;
171
+ }, z.core.$strict>;
172
+ condition: z.ZodOptional<z.ZodObject<{
173
+ name: z.ZodString;
174
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
175
+ }, z.core.$strict>>;
176
+ }, z.core.$strict>>;
177
+ revokeIntentId: z.ZodOptional<z.ZodString>;
178
+ }, z.core.$strict>, z.ZodObject<{
179
+ kind: z.ZodLiteral<FactChangeKind.DesiredState>;
180
+ object: z.ZodObject<{
181
+ type: z.ZodString;
182
+ id: z.ZodString;
183
+ }, z.core.$strict>;
184
+ version: z.ZodNumber;
185
+ relations: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
186
+ subject: z.ZodObject<{
187
+ type: z.ZodString;
188
+ id: z.ZodString;
189
+ relation: z.ZodOptional<z.ZodString>;
190
+ }, z.core.$strict>;
191
+ condition: z.ZodOptional<z.ZodObject<{
192
+ name: z.ZodString;
193
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
194
+ }, z.core.$strict>>;
195
+ }, z.core.$strict>>>;
196
+ revokeIntentId: z.ZodOptional<z.ZodString>;
197
+ }, z.core.$strict>, z.ZodObject<{
198
+ kind: z.ZodLiteral<FactChangeKind.DeleteObject>;
199
+ object: z.ZodObject<{
200
+ type: z.ZodString;
201
+ id: z.ZodString;
202
+ }, z.core.$strict>;
203
+ version: z.ZodNumber;
204
+ }, z.core.$strict>], "kind">>;
205
+ }, z.core.$strict>;
206
+ export type FactsApplyRequest = z.infer<typeof FactsApplyRequestSchema>;
207
+ export declare enum FactChangeOutcome {
208
+ Applied = "applied",
209
+ Superseded = "superseded",
210
+ Tombstoned = "tombstoned"
211
+ }
212
+ export declare const FactChangeOutcomeSchema: z.ZodEnum<typeof FactChangeOutcome>;
213
+ export declare const FactChangeResultSchema: z.ZodObject<{
214
+ object: z.ZodObject<{
215
+ type: z.ZodString;
216
+ id: z.ZodString;
217
+ }, z.core.$strict>;
218
+ outcome: z.ZodEnum<typeof FactChangeOutcome>;
219
+ recordedVersion: z.ZodNumber;
220
+ }, z.core.$strict>;
221
+ export type FactChangeResult = z.infer<typeof FactChangeResultSchema>;
222
+ export declare const FactsApplyResponseSchema: z.ZodObject<{
223
+ results: z.ZodArray<z.ZodObject<{
224
+ object: z.ZodObject<{
225
+ type: z.ZodString;
226
+ id: z.ZodString;
227
+ }, z.core.$strict>;
228
+ outcome: z.ZodEnum<typeof FactChangeOutcome>;
229
+ recordedVersion: z.ZodNumber;
230
+ }, z.core.$strict>>;
231
+ written: z.ZodNumber;
232
+ deleted: z.ZodNumber;
233
+ }, z.core.$strict>;
234
+ export type FactsApplyResponse = z.infer<typeof FactsApplyResponseSchema>;
235
+ export declare enum FactsApplyRefusal {
236
+ WriterMismatch = "writer_mismatch",
237
+ TypeNotWritable = "type_not_writable",
238
+ RelationNotWritable = "relation_not_writable",
239
+ TenantMismatch = "tenant_mismatch",
240
+ TooManyTuples = "too_many_tuples",
241
+ TupleNotAdmittedByModel = "tuple_not_admitted_by_model"
242
+ }
243
+ export declare const FactsApplyRefusalSchema: z.ZodEnum<typeof FactsApplyRefusal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eAAO,MAAM,sBAAsB;;;;;;;kBAOxB,CAAC;AACZ,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAMtE,eAAO,MAAM,wBAAwB;;;;;;;;;;;kBAM1B,CAAC;AACZ,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAM1E,oBAAY,iBAAiB;IAE3B,cAAc,oBAAoB;IAElC,eAAe,sBAAsB;IAErC,mBAAmB,0BAA0B;IAE7C,cAAc,oBAAoB;IAElC,aAAa,oBAAoB;IAEjC,uBAAuB,gCAAgC;CACxD;AAED,eAAO,MAAM,uBAAuB,qCAAkC,CAAC"}
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FactsApplyRefusalSchema = exports.FactsApplyRefusal = exports.FactsApplyResponseSchema = exports.FactChangeResultSchema = exports.FactChangeOutcomeSchema = exports.FactChangeOutcome = exports.FactsApplyRequestSchema = exports.FactChangeSchema = exports.DeleteObjectFactChangeSchema = exports.DesiredStateFactChangeSchema = exports.DesiredFactSubjectSchema = exports.DeltaFactChangeSchema = exports.FactChangeKindSchema = exports.FactChangeKind = exports.FactsVersionSchema = exports.FACTS_APPLY_MAX_TUPLES = void 0;
4
+ exports.namedTupleCount = namedTupleCount;
5
+ const zod_1 = require("zod");
6
+ const fact_tuple_1 = require("./fact-tuple");
7
+ exports.FACTS_APPLY_MAX_TUPLES = 100;
8
+ exports.FactsVersionSchema = zod_1.z.number().int().positive();
9
+ var FactChangeKind;
10
+ (function (FactChangeKind) {
11
+ FactChangeKind["Delta"] = "delta";
12
+ FactChangeKind["DesiredState"] = "desired-state";
13
+ FactChangeKind["DeleteObject"] = "delete-object";
14
+ })(FactChangeKind || (exports.FactChangeKind = FactChangeKind = {}));
15
+ exports.FactChangeKindSchema = zod_1.z.nativeEnum(FactChangeKind);
16
+ exports.DeltaFactChangeSchema = zod_1.z
17
+ .object({
18
+ kind: zod_1.z.literal(FactChangeKind.Delta),
19
+ object: fact_tuple_1.FactObjectRefSchema,
20
+ version: exports.FactsVersionSchema,
21
+ writes: zod_1.z.array(fact_tuple_1.FactTupleSchema),
22
+ deletes: zod_1.z.array(fact_tuple_1.FactTupleSchema),
23
+ revokeIntentId: zod_1.z.string().min(1).optional(),
24
+ })
25
+ .strict()
26
+ .refine((c) => c.writes.length + c.deletes.length > 0, {
27
+ message: 'a delta change carries at least one write or delete.',
28
+ });
29
+ exports.DesiredFactSubjectSchema = zod_1.z
30
+ .object({
31
+ subject: fact_tuple_1.FactSubjectRefSchema,
32
+ condition: fact_tuple_1.FactConditionSchema.optional(),
33
+ })
34
+ .strict();
35
+ exports.DesiredStateFactChangeSchema = zod_1.z
36
+ .object({
37
+ kind: zod_1.z.literal(FactChangeKind.DesiredState),
38
+ object: fact_tuple_1.FactObjectRefSchema,
39
+ version: exports.FactsVersionSchema,
40
+ relations: zod_1.z.record(fact_tuple_1.FactRelationSchema, zod_1.z.array(exports.DesiredFactSubjectSchema)),
41
+ revokeIntentId: zod_1.z.string().min(1).optional(),
42
+ })
43
+ .strict();
44
+ exports.DeleteObjectFactChangeSchema = zod_1.z
45
+ .object({
46
+ kind: zod_1.z.literal(FactChangeKind.DeleteObject),
47
+ object: fact_tuple_1.FactObjectRefSchema,
48
+ version: exports.FactsVersionSchema,
49
+ })
50
+ .strict();
51
+ exports.FactChangeSchema = zod_1.z.discriminatedUnion('kind', [
52
+ exports.DeltaFactChangeSchema,
53
+ exports.DesiredStateFactChangeSchema,
54
+ exports.DeleteObjectFactChangeSchema,
55
+ ]);
56
+ function namedTupleCount(change) {
57
+ switch (change.kind) {
58
+ case FactChangeKind.Delta:
59
+ return change.writes.length + change.deletes.length;
60
+ case FactChangeKind.DesiredState:
61
+ return Object.values(change.relations).reduce((sum, subjects) => sum + subjects.length, 0);
62
+ case FactChangeKind.DeleteObject:
63
+ return 0;
64
+ }
65
+ }
66
+ function objectKey(object) {
67
+ return `${object.type}:${object.id}`;
68
+ }
69
+ exports.FactsApplyRequestSchema = zod_1.z
70
+ .object({
71
+ orgId: zod_1.z.string().min(1),
72
+ biomeId: zod_1.z.string().min(1),
73
+ changes: zod_1.z.array(exports.FactChangeSchema).min(1),
74
+ })
75
+ .strict()
76
+ .superRefine((request, ctx) => {
77
+ const seen = new Set();
78
+ request.changes.forEach((change, index) => {
79
+ const key = objectKey(change.object);
80
+ if (seen.has(key)) {
81
+ ctx.addIssue({
82
+ code: 'custom',
83
+ path: ['changes', index, 'object'],
84
+ message: `object ${key} appears twice in one request; one change per object, so the order of its facts is never ambiguous.`,
85
+ });
86
+ }
87
+ seen.add(key);
88
+ if (change.kind === FactChangeKind.Delta) {
89
+ const writes = new Set(change.writes.map((t) => (0, fact_tuple_1.factTupleKey)(change.object, t)));
90
+ for (const tuple of change.deletes) {
91
+ if (writes.has((0, fact_tuple_1.factTupleKey)(change.object, tuple))) {
92
+ ctx.addIssue({
93
+ code: 'custom',
94
+ path: ['changes', index],
95
+ message: `tuple ${(0, fact_tuple_1.factTupleKey)(change.object, tuple)} is both written and deleted in one change.`,
96
+ });
97
+ }
98
+ }
99
+ }
100
+ });
101
+ const named = request.changes.reduce((s, c) => s + namedTupleCount(c), 0);
102
+ if (named > exports.FACTS_APPLY_MAX_TUPLES) {
103
+ ctx.addIssue({
104
+ code: 'custom',
105
+ path: ['changes'],
106
+ message: `the request names ${named} tuples; the limit is ${exports.FACTS_APPLY_MAX_TUPLES} and a request is refused, never split.`,
107
+ });
108
+ }
109
+ });
110
+ var FactChangeOutcome;
111
+ (function (FactChangeOutcome) {
112
+ FactChangeOutcome["Applied"] = "applied";
113
+ FactChangeOutcome["Superseded"] = "superseded";
114
+ FactChangeOutcome["Tombstoned"] = "tombstoned";
115
+ })(FactChangeOutcome || (exports.FactChangeOutcome = FactChangeOutcome = {}));
116
+ exports.FactChangeOutcomeSchema = zod_1.z.nativeEnum(FactChangeOutcome);
117
+ exports.FactChangeResultSchema = zod_1.z
118
+ .object({
119
+ object: fact_tuple_1.FactObjectRefSchema,
120
+ outcome: exports.FactChangeOutcomeSchema,
121
+ recordedVersion: exports.FactsVersionSchema,
122
+ })
123
+ .strict();
124
+ exports.FactsApplyResponseSchema = zod_1.z
125
+ .object({
126
+ results: zod_1.z.array(exports.FactChangeResultSchema),
127
+ written: zod_1.z.number().int().nonnegative(),
128
+ deleted: zod_1.z.number().int().nonnegative(),
129
+ })
130
+ .strict();
131
+ var FactsApplyRefusal;
132
+ (function (FactsApplyRefusal) {
133
+ FactsApplyRefusal["WriterMismatch"] = "writer_mismatch";
134
+ FactsApplyRefusal["TypeNotWritable"] = "type_not_writable";
135
+ FactsApplyRefusal["RelationNotWritable"] = "relation_not_writable";
136
+ FactsApplyRefusal["TenantMismatch"] = "tenant_mismatch";
137
+ FactsApplyRefusal["TooManyTuples"] = "too_many_tuples";
138
+ FactsApplyRefusal["TupleNotAdmittedByModel"] = "tuple_not_admitted_by_model";
139
+ })(FactsApplyRefusal || (exports.FactsApplyRefusal = FactsApplyRefusal = {}));
140
+ exports.FactsApplyRefusalSchema = zod_1.z.nativeEnum(FactsApplyRefusal);
141
+ //# sourceMappingURL=facts-apply.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"facts-apply.js","sourceRoot":"","sources":["../../../src/authorization-facts/lib/facts-apply.ts"],"names":[],"mappings":";;;AAmHA,0CAYC;AA/HD,6BAAwB;AAExB,6CAQsB;AA+BT,QAAA,sBAAsB,GAAG,GAAG,CAAC;AAG7B,QAAA,kBAAkB,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;AAe9D,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,iCAAe,CAAA;IACf,gDAA8B,CAAA;IAC9B,gDAA8B,CAAA;AAChC,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB;AAEY,QAAA,oBAAoB,GAAG,OAAC,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C,EAbW,iBAAiB,iCAAjB,iBAAiB,QAa5B;AAEY,QAAA,uBAAuB,GAAG,OAAC,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,70 @@
1
+ import { z } from 'zod';
2
+ export declare const FactsSnapshotPageRequestSchema: z.ZodObject<{
3
+ orgId: z.ZodString;
4
+ type: z.ZodString;
5
+ cursor: z.ZodOptional<z.ZodString>;
6
+ limit: z.ZodNumber;
7
+ }, z.core.$strict>;
8
+ export type FactsSnapshotPageRequest = z.infer<typeof FactsSnapshotPageRequestSchema>;
9
+ export declare const FactsSnapshotPageResponseSchema: z.ZodObject<{
10
+ changes: z.ZodArray<z.ZodObject<{
11
+ kind: z.ZodLiteral<import("./facts-apply").FactChangeKind.DesiredState>;
12
+ object: z.ZodObject<{
13
+ type: z.ZodString;
14
+ id: z.ZodString;
15
+ }, z.core.$strict>;
16
+ version: z.ZodNumber;
17
+ relations: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
18
+ subject: z.ZodObject<{
19
+ type: z.ZodString;
20
+ id: z.ZodString;
21
+ relation: z.ZodOptional<z.ZodString>;
22
+ }, z.core.$strict>;
23
+ condition: z.ZodOptional<z.ZodObject<{
24
+ name: z.ZodString;
25
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
26
+ }, z.core.$strict>>;
27
+ }, z.core.$strict>>>;
28
+ revokeIntentId: z.ZodOptional<z.ZodString>;
29
+ }, z.core.$strict>>;
30
+ nextCursor: z.ZodString;
31
+ }, z.core.$strict>;
32
+ export type FactsSnapshotPageResponse = z.infer<typeof FactsSnapshotPageResponseSchema>;
33
+ export declare const FactsSnapshotObjectRequestSchema: z.ZodObject<{
34
+ orgId: z.ZodString;
35
+ object: z.ZodObject<{
36
+ type: z.ZodString;
37
+ id: z.ZodString;
38
+ }, z.core.$strict>;
39
+ }, z.core.$strict>;
40
+ export declare const FactsSnapshotObjectResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
41
+ deleted: z.ZodLiteral<false>;
42
+ change: z.ZodObject<{
43
+ kind: z.ZodLiteral<import("./facts-apply").FactChangeKind.DesiredState>;
44
+ object: z.ZodObject<{
45
+ type: z.ZodString;
46
+ id: z.ZodString;
47
+ }, z.core.$strict>;
48
+ version: z.ZodNumber;
49
+ relations: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
50
+ subject: z.ZodObject<{
51
+ type: z.ZodString;
52
+ id: z.ZodString;
53
+ relation: z.ZodOptional<z.ZodString>;
54
+ }, z.core.$strict>;
55
+ condition: z.ZodOptional<z.ZodObject<{
56
+ name: z.ZodString;
57
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
58
+ }, z.core.$strict>>;
59
+ }, z.core.$strict>>>;
60
+ revokeIntentId: z.ZodOptional<z.ZodString>;
61
+ }, z.core.$strict>;
62
+ }, z.core.$strict>, z.ZodObject<{
63
+ deleted: z.ZodLiteral<true>;
64
+ object: z.ZodObject<{
65
+ type: z.ZodString;
66
+ id: z.ZodString;
67
+ }, z.core.$strict>;
68
+ version: z.ZodNumber;
69
+ }, z.core.$strict>], "deleted">;
70
+ //# sourceMappingURL=facts-snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"facts-snapshot.d.ts","sourceRoot":"","sources":["../../../src/authorization-facts/lib/facts-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBxB,eAAO,MAAM,8BAA8B;;;;;kBAQhC,CAAC;AACZ,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,8BAA8B,CACtC,CAAC;AAEF,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;kBAMjC,CAAC;AACZ,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,CAAC;AAGF,eAAO,MAAM,gCAAgC;;;;;;kBAKlC,CAAC;AAMZ,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAc7C,CAAC"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FactsSnapshotObjectResponseSchema = exports.FactsSnapshotObjectRequestSchema = exports.FactsSnapshotPageResponseSchema = exports.FactsSnapshotPageRequestSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const fact_tuple_1 = require("./fact-tuple");
6
+ const facts_apply_1 = require("./facts-apply");
7
+ exports.FactsSnapshotPageRequestSchema = zod_1.z
8
+ .object({
9
+ orgId: zod_1.z.string().min(1),
10
+ type: fact_tuple_1.FactTypeSchema,
11
+ cursor: zod_1.z.string().min(1).optional(),
12
+ limit: zod_1.z.number().int().positive().max(500),
13
+ })
14
+ .strict();
15
+ exports.FactsSnapshotPageResponseSchema = zod_1.z
16
+ .object({
17
+ changes: zod_1.z.array(facts_apply_1.DesiredStateFactChangeSchema),
18
+ nextCursor: zod_1.z.string(),
19
+ })
20
+ .strict();
21
+ exports.FactsSnapshotObjectRequestSchema = zod_1.z
22
+ .object({
23
+ orgId: zod_1.z.string().min(1),
24
+ object: fact_tuple_1.FactObjectRefSchema,
25
+ })
26
+ .strict();
27
+ exports.FactsSnapshotObjectResponseSchema = zod_1.z.discriminatedUnion('deleted', [
28
+ zod_1.z
29
+ .object({ deleted: zod_1.z.literal(false), change: facts_apply_1.DesiredStateFactChangeSchema })
30
+ .strict(),
31
+ zod_1.z
32
+ .object({
33
+ deleted: zod_1.z.literal(true),
34
+ object: fact_tuple_1.FactObjectRefSchema,
35
+ version: zod_1.z.number().int().positive(),
36
+ })
37
+ .strict(),
38
+ ]);
39
+ //# sourceMappingURL=facts-snapshot.js.map