@nakafa/aksara-contracts 0.27.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 (269) hide show
  1. package/LICENSE +185 -0
  2. package/README.md +73 -0
  3. package/dist/artifact/integrity.d.ts +29 -0
  4. package/dist/artifact/integrity.js +54 -0
  5. package/dist/artifact/limits.d.ts +26 -0
  6. package/dist/artifact/limits.js +46 -0
  7. package/dist/artifact/source.d.ts +21 -0
  8. package/dist/artifact/source.js +24 -0
  9. package/dist/artifact/spec.d.ts +148 -0
  10. package/dist/artifact/spec.js +92 -0
  11. package/dist/artifact/verify.d.ts +26 -0
  12. package/dist/artifact/verify.js +18 -0
  13. package/dist/cache/content.d.ts +52 -0
  14. package/dist/cache/content.js +80 -0
  15. package/dist/content.d.ts +168 -0
  16. package/dist/content.js +107 -0
  17. package/dist/country.d.ts +4 -0
  18. package/dist/country.js +8 -0
  19. package/dist/date.d.ts +24 -0
  20. package/dist/date.js +44 -0
  21. package/dist/decode.d.ts +4 -0
  22. package/dist/decode.js +8 -0
  23. package/dist/delivery.d.ts +4 -0
  24. package/dist/delivery.js +7 -0
  25. package/dist/errors.d.ts +10 -0
  26. package/dist/errors.js +8 -0
  27. package/dist/graph/family.d.ts +45 -0
  28. package/dist/graph/family.js +85 -0
  29. package/dist/graph/identity.d.ts +19 -0
  30. package/dist/graph/identity.js +39 -0
  31. package/dist/graph/spec.d.ts +20 -0
  32. package/dist/graph/spec.js +26 -0
  33. package/dist/hash/text.d.ts +10 -0
  34. package/dist/hash/text.js +20 -0
  35. package/dist/ids.d.ts +27 -0
  36. package/dist/ids.js +63 -0
  37. package/dist/limits.d.ts +10 -0
  38. package/dist/limits.js +10 -0
  39. package/dist/locale.d.ts +37 -0
  40. package/dist/locale.js +53 -0
  41. package/dist/material/domain.d.ts +4 -0
  42. package/dist/material/domain.js +8 -0
  43. package/dist/preview/artifact.d.ts +198 -0
  44. package/dist/preview/artifact.js +20 -0
  45. package/dist/preview/auth.d.ts +71 -0
  46. package/dist/preview/auth.js +49 -0
  47. package/dist/preview/document.d.ts +692 -0
  48. package/dist/preview/document.js +90 -0
  49. package/dist/preview/spec.d.ts +2517 -0
  50. package/dist/preview/spec.js +142 -0
  51. package/dist/preview/target.d.ts +172 -0
  52. package/dist/preview/target.js +70 -0
  53. package/dist/program/curriculum.d.ts +69 -0
  54. package/dist/program/curriculum.js +181 -0
  55. package/dist/program/snapshot/digest.d.ts +26 -0
  56. package/dist/program/snapshot/digest.js +220 -0
  57. package/dist/program/snapshot/hash.d.ts +31 -0
  58. package/dist/program/snapshot/hash.js +40 -0
  59. package/dist/program/snapshot/row-hash.d.ts +155 -0
  60. package/dist/program/snapshot/row-hash.js +34 -0
  61. package/dist/program/snapshot/row.d.ts +139 -0
  62. package/dist/program/snapshot/row.js +28 -0
  63. package/dist/program/snapshot/spec.d.ts +36 -0
  64. package/dist/program/snapshot/spec.js +39 -0
  65. package/dist/program/spec.d.ts +85 -0
  66. package/dist/program/spec.js +197 -0
  67. package/dist/projection/article.d.ts +145 -0
  68. package/dist/projection/article.js +150 -0
  69. package/dist/projection/digest.d.ts +261 -0
  70. package/dist/projection/digest.js +59 -0
  71. package/dist/projection/hash.d.ts +3 -0
  72. package/dist/projection/hash.js +10 -0
  73. package/dist/projection/material.d.ts +109 -0
  74. package/dist/projection/material.js +160 -0
  75. package/dist/projection/page.d.ts +112 -0
  76. package/dist/projection/page.js +106 -0
  77. package/dist/projection/question.d.ts +520 -0
  78. package/dist/projection/question.js +109 -0
  79. package/dist/projection/spec.d.ts +503 -0
  80. package/dist/projection/spec.js +56 -0
  81. package/dist/projection/verify.d.ts +281 -0
  82. package/dist/projection/verify.js +86 -0
  83. package/dist/question/identity.d.ts +175 -0
  84. package/dist/question/identity.js +205 -0
  85. package/dist/question/item.d.ts +453 -0
  86. package/dist/question/item.js +146 -0
  87. package/dist/question/response.d.ts +175 -0
  88. package/dist/question/response.js +150 -0
  89. package/dist/quran/attribution.d.ts +48 -0
  90. package/dist/quran/attribution.js +44 -0
  91. package/dist/quran/identity.d.ts +105 -0
  92. package/dist/quran/identity.js +100 -0
  93. package/dist/quran/notes.d.ts +56 -0
  94. package/dist/quran/notes.js +142 -0
  95. package/dist/quran/provenance.d.ts +257 -0
  96. package/dist/quran/provenance.js +144 -0
  97. package/dist/quran/snapshot/digest.d.ts +33 -0
  98. package/dist/quran/snapshot/digest.js +232 -0
  99. package/dist/quran/snapshot/hash.d.ts +51 -0
  100. package/dist/quran/snapshot/hash.js +50 -0
  101. package/dist/quran/snapshot/row/hash.d.ts +748 -0
  102. package/dist/quran/snapshot/row/hash.js +115 -0
  103. package/dist/quran/snapshot/row.d.ts +354 -0
  104. package/dist/quran/snapshot/row.js +91 -0
  105. package/dist/quran/snapshot/spec.d.ts +50 -0
  106. package/dist/quran/snapshot/spec.js +66 -0
  107. package/dist/quran/source.d.ts +206 -0
  108. package/dist/quran/source.js +153 -0
  109. package/dist/quran/spec.d.ts +47 -0
  110. package/dist/quran/spec.js +41 -0
  111. package/dist/quran/text.d.ts +7 -0
  112. package/dist/quran/text.js +11 -0
  113. package/dist/release/canonical.d.ts +23 -0
  114. package/dist/release/canonical.js +29 -0
  115. package/dist/release/current/evidence.d.ts +424 -0
  116. package/dist/release/current/evidence.js +41 -0
  117. package/dist/release/current/runtime.d.ts +4 -0
  118. package/dist/release/current/runtime.js +15 -0
  119. package/dist/release/current/state.d.ts +567 -0
  120. package/dist/release/current/state.js +91 -0
  121. package/dist/release/digest.d.ts +54 -0
  122. package/dist/release/digest.js +71 -0
  123. package/dist/release/hash.d.ts +72 -0
  124. package/dist/release/hash.js +14 -0
  125. package/dist/release/head.d.ts +206 -0
  126. package/dist/release/head.js +131 -0
  127. package/dist/release/items.d.ts +98 -0
  128. package/dist/release/items.js +114 -0
  129. package/dist/release/lifecycle.d.ts +297 -0
  130. package/dist/release/lifecycle.js +97 -0
  131. package/dist/release/origin.d.ts +30 -0
  132. package/dist/release/origin.js +24 -0
  133. package/dist/release/policy.d.ts +45 -0
  134. package/dist/release/policy.js +124 -0
  135. package/dist/release/result/digest.d.ts +127 -0
  136. package/dist/release/result/digest.js +140 -0
  137. package/dist/release/result/spec.d.ts +4 -0
  138. package/dist/release/result/spec.js +5 -0
  139. package/dist/release/rollback/digest.d.ts +126 -0
  140. package/dist/release/rollback/digest.js +92 -0
  141. package/dist/release/rollback/spec.d.ts +1729 -0
  142. package/dist/release/rollback/spec.js +156 -0
  143. package/dist/release/route/digest.d.ts +45 -0
  144. package/dist/release/route/digest.js +59 -0
  145. package/dist/release/route/page.d.ts +56 -0
  146. package/dist/release/route/page.js +46 -0
  147. package/dist/release/route/spec.d.ts +49 -0
  148. package/dist/release/route/spec.js +40 -0
  149. package/dist/release/route/verify.d.ts +66 -0
  150. package/dist/release/route/verify.js +67 -0
  151. package/dist/release/signing.d.ts +6 -0
  152. package/dist/release/signing.js +38 -0
  153. package/dist/release/snapshot/data.d.ts +475 -0
  154. package/dist/release/snapshot/data.js +74 -0
  155. package/dist/release/snapshot/evidence-requirement.d.ts +22 -0
  156. package/dist/release/snapshot/evidence-requirement.js +21 -0
  157. package/dist/release/snapshot/evidence.d.ts +58 -0
  158. package/dist/release/snapshot/evidence.js +14 -0
  159. package/dist/release/snapshot/program-evidence.d.ts +17 -0
  160. package/dist/release/snapshot/program-evidence.js +39 -0
  161. package/dist/release/snapshot/quran-evidence.d.ts +27 -0
  162. package/dist/release/snapshot/quran-evidence.js +43 -0
  163. package/dist/release/snapshot/scope.d.ts +60 -0
  164. package/dist/release/snapshot/scope.js +102 -0
  165. package/dist/release/snapshot/spec.d.ts +193 -0
  166. package/dist/release/snapshot/spec.js +139 -0
  167. package/dist/release/snapshot/tryout-evidence.d.ts +22 -0
  168. package/dist/release/snapshot/tryout-evidence.js +86 -0
  169. package/dist/release/snapshot/verify.d.ts +710 -0
  170. package/dist/release/snapshot/verify.js +147 -0
  171. package/dist/release/spec.d.ts +491 -0
  172. package/dist/release/spec.js +200 -0
  173. package/dist/release/verify.d.ts +98 -0
  174. package/dist/release/verify.js +70 -0
  175. package/dist/renderer/compatibility.d.ts +35 -0
  176. package/dist/renderer/compatibility.js +48 -0
  177. package/dist/renderer/component.d.ts +99 -0
  178. package/dist/renderer/component.js +102 -0
  179. package/dist/renderer/contract.d.ts +144 -0
  180. package/dist/renderer/contract.js +122 -0
  181. package/dist/renderer/domain.d.ts +6 -0
  182. package/dist/renderer/domain.js +18 -0
  183. package/dist/renderer/manifest.d.ts +86 -0
  184. package/dist/renderer/manifest.js +49 -0
  185. package/dist/renderer/selection.d.ts +39 -0
  186. package/dist/renderer/selection.js +87 -0
  187. package/dist/runtime/error.d.ts +8 -0
  188. package/dist/runtime/error.js +20 -0
  189. package/dist/runtime/protected/limits.d.ts +10 -0
  190. package/dist/runtime/protected/limits.js +15 -0
  191. package/dist/runtime/protected/spec.d.ts +328 -0
  192. package/dist/runtime/protected/spec.js +79 -0
  193. package/dist/runtime/protected/verify.d.ts +97 -0
  194. package/dist/runtime/protected/verify.js +72 -0
  195. package/dist/runtime/result.d.ts +12 -0
  196. package/dist/runtime/result.js +17 -0
  197. package/dist/runtime/spec.d.ts +705 -0
  198. package/dist/runtime/spec.js +61 -0
  199. package/dist/runtime/verify.d.ts +479 -0
  200. package/dist/runtime/verify.js +123 -0
  201. package/dist/signature/spec.d.ts +53 -0
  202. package/dist/signature/spec.js +29 -0
  203. package/dist/signature/trusted.d.ts +19 -0
  204. package/dist/signature/trusted.js +32 -0
  205. package/dist/signature/verify.d.ts +10 -0
  206. package/dist/signature/verify.js +82 -0
  207. package/dist/text/order.d.ts +2 -0
  208. package/dist/text/order.js +10 -0
  209. package/dist/text/syntax.d.ts +6 -0
  210. package/dist/text/syntax.js +15 -0
  211. package/dist/transport/batch.d.ts +971 -0
  212. package/dist/transport/batch.js +101 -0
  213. package/dist/transport/failure.d.ts +168 -0
  214. package/dist/transport/failure.js +194 -0
  215. package/dist/transport/group.d.ts +2946 -0
  216. package/dist/transport/group.js +47 -0
  217. package/dist/transport/limits.d.ts +30 -0
  218. package/dist/transport/limits.js +30 -0
  219. package/dist/transport/request.d.ts +9333 -0
  220. package/dist/transport/request.js +121 -0
  221. package/dist/transport/response.d.ts +6247 -0
  222. package/dist/transport/response.js +181 -0
  223. package/dist/transport/runtime.d.ts +77 -0
  224. package/dist/transport/runtime.js +33 -0
  225. package/dist/transport/snapshot.d.ts +978 -0
  226. package/dist/transport/snapshot.js +70 -0
  227. package/dist/tryout/canonical.d.ts +2 -0
  228. package/dist/tryout/canonical.js +11 -0
  229. package/dist/tryout/catalog-hash.d.ts +134 -0
  230. package/dist/tryout/catalog-hash.js +203 -0
  231. package/dist/tryout/catalog.d.ts +376 -0
  232. package/dist/tryout/catalog.js +147 -0
  233. package/dist/tryout/content-hash.d.ts +89 -0
  234. package/dist/tryout/content-hash.js +72 -0
  235. package/dist/tryout/identity.d.ts +12 -0
  236. package/dist/tryout/identity.js +46 -0
  237. package/dist/tryout/key.d.ts +4 -0
  238. package/dist/tryout/key.js +8 -0
  239. package/dist/tryout/language.d.ts +24 -0
  240. package/dist/tryout/language.js +32 -0
  241. package/dist/tryout/locale-closure.d.ts +20 -0
  242. package/dist/tryout/locale-closure.js +164 -0
  243. package/dist/tryout/placement-closure.d.ts +5 -0
  244. package/dist/tryout/placement-closure.js +30 -0
  245. package/dist/tryout/placement-hash.d.ts +11 -0
  246. package/dist/tryout/placement-hash.js +55 -0
  247. package/dist/tryout/placement.d.ts +280 -0
  248. package/dist/tryout/placement.js +82 -0
  249. package/dist/tryout/row-hash.d.ts +28 -0
  250. package/dist/tryout/row-hash.js +50 -0
  251. package/dist/tryout/runtime/canonical.d.ts +8 -0
  252. package/dist/tryout/runtime/canonical.js +33 -0
  253. package/dist/tryout/runtime/hash.d.ts +32 -0
  254. package/dist/tryout/runtime/hash.js +11 -0
  255. package/dist/tryout/runtime/source.d.ts +42 -0
  256. package/dist/tryout/runtime/source.js +47 -0
  257. package/dist/tryout/runtime/spec.d.ts +58 -0
  258. package/dist/tryout/runtime/spec.js +21 -0
  259. package/dist/tryout/runtime/verify.d.ts +61 -0
  260. package/dist/tryout/runtime/verify.js +69 -0
  261. package/dist/tryout/snapshot/canonical.d.ts +7 -0
  262. package/dist/tryout/snapshot/canonical.js +17 -0
  263. package/dist/tryout/snapshot/hash.d.ts +8 -0
  264. package/dist/tryout/snapshot/hash.js +19 -0
  265. package/dist/tryout/snapshot/spec.d.ts +46 -0
  266. package/dist/tryout/snapshot/spec.js +30 -0
  267. package/dist/tryout/spec.d.ts +13 -0
  268. package/dist/tryout/spec.js +15 -0
  269. package/package.json +506 -0
@@ -0,0 +1,101 @@
1
+ import { Schema } from "effect";
2
+ import { SignedContentArtifactSchema } from "#contracts/content";
3
+ import { ReleaseIdSchema } from "#contracts/ids";
4
+ import { ContentProjectionSchema, CurrentContentProjectionSchema, } from "#contracts/projection/spec";
5
+ import { ContentRouteItemSchema } from "#contracts/release/route/spec";
6
+ import { ContentReleaseItemSchema } from "#contracts/release/spec";
7
+ import { MAX_ARTIFACT_BATCH_COUNT, MAX_ITEM_BATCH_COUNT, MAX_PROJECTION_BATCH_COUNT, MAX_ROUTE_BATCH_COUNT, } from "#contracts/transport/limits";
8
+ const BatchIndexSchema = Schema.Finite.pipe(Schema.check(Schema.isInt()), Schema.check(Schema.isGreaterThanOrEqualTo(0)));
9
+ const ReleaseItemBatchSchema = Schema.NonEmptyArray(ContentReleaseItemSchema).pipe(Schema.check(Schema.isMaxLength(MAX_ITEM_BATCH_COUNT)));
10
+ const StageItemBatchFields = {
11
+ batchIndex: BatchIndexSchema,
12
+ items: ReleaseItemBatchSchema,
13
+ releaseId: ReleaseIdSchema,
14
+ };
15
+ /** Checks batch ownership and contiguous signed item indexes. */
16
+ function hasBoundReleaseItems(input) {
17
+ const [first] = input.items;
18
+ return input.items.every((item, offset) => item.releaseId === input.releaseId && item.index === first.index + offset);
19
+ }
20
+ /** Canonical input for one bounded ordered-item staging operation. */
21
+ export const StageItemBatchInputSchema = Schema.Struct(StageItemBatchFields).pipe(Schema.check(Schema.makeFilter(hasBoundReleaseItems, {
22
+ message: "Expected contiguous release items bound to the batch release identity.",
23
+ })));
24
+ /**
25
+ * Stages one non-empty bounded batch of ordered signed release items.
26
+ *
27
+ * Rollback targets bind each upsert to its retained immutable artifact here;
28
+ * later verification must reject any missing or mismatched retained body.
29
+ */
30
+ export const StageItemBatchRequestSchema = Schema.Struct({
31
+ ...StageItemBatchFields,
32
+ operation: Schema.Literal("stageItemBatch"),
33
+ }).pipe(Schema.check(Schema.makeFilter(hasBoundReleaseItems, {
34
+ message: "Expected contiguous release items bound to the batch release identity.",
35
+ })));
36
+ const RouteItemBatchSchema = Schema.NonEmptyArray(ContentRouteItemSchema).pipe(Schema.check(Schema.isMaxLength(MAX_ROUTE_BATCH_COUNT)));
37
+ const StageRouteBatchFields = {
38
+ batchIndex: BatchIndexSchema,
39
+ releaseId: ReleaseIdSchema,
40
+ routes: RouteItemBatchSchema,
41
+ };
42
+ /** Checks batch ownership and contiguous signed route indexes. */
43
+ function hasBoundRouteItems(input) {
44
+ const [first] = input.routes;
45
+ return input.routes.every((route, offset) => route.releaseId === input.releaseId &&
46
+ route.index === first.index + offset);
47
+ }
48
+ /** Canonical input for one bounded ordered-route staging operation. */
49
+ export const StageRouteBatchInputSchema = Schema.Struct(StageRouteBatchFields).pipe(Schema.check(Schema.makeFilter(hasBoundRouteItems, {
50
+ message: "Expected contiguous route items bound to the batch release identity.",
51
+ })));
52
+ /** Stages one non-empty bounded batch of ordered signed route items. */
53
+ export const StageRouteBatchRequestSchema = Schema.Struct({
54
+ ...StageRouteBatchFields,
55
+ operation: Schema.Literal("stageRouteBatch"),
56
+ }).pipe(Schema.check(Schema.makeFilter(hasBoundRouteItems, {
57
+ message: "Expected contiguous route items bound to the batch release identity.",
58
+ })));
59
+ const StageProjectionBatchFields = {
60
+ batchIndex: BatchIndexSchema,
61
+ projections: Schema.NonEmptyArray(CurrentContentProjectionSchema).pipe(Schema.check(Schema.isMaxLength(MAX_PROJECTION_BATCH_COUNT))),
62
+ releaseId: ReleaseIdSchema,
63
+ };
64
+ /** Canonical input for one bounded projection staging operation. */
65
+ export const StageProjectionBatchInputSchema = Schema.Struct(StageProjectionBatchFields);
66
+ /** Stages one non-empty bounded batch of canonical content projections. */
67
+ export const StageProjectionBatchRequestSchema = Schema.Struct({
68
+ ...StageProjectionBatchFields,
69
+ operation: Schema.Literal("stageProjectionBatch"),
70
+ });
71
+ const StageRollbackProjectionBatchFields = {
72
+ batchIndex: BatchIndexSchema,
73
+ projections: Schema.NonEmptyArray(ContentProjectionSchema).pipe(Schema.check(Schema.isMaxLength(MAX_PROJECTION_BATCH_COUNT))),
74
+ releaseId: ReleaseIdSchema,
75
+ };
76
+ /** Canonical input reserved for one authenticated rollback release. */
77
+ export const StageRollbackProjectionBatchInputSchema = Schema.Struct(StageRollbackProjectionBatchFields);
78
+ /** Carries historical projections only inside a rollback staging group. */
79
+ export const StageRollbackProjectionBatchRequestSchema = Schema.Struct({
80
+ ...StageRollbackProjectionBatchFields,
81
+ operation: Schema.Literal("stageRollbackProjectionBatch"),
82
+ });
83
+ const StageArtifactBatchFields = {
84
+ artifacts: Schema.NonEmptyArray(SignedContentArtifactSchema).pipe(Schema.check(Schema.isMaxLength(MAX_ARTIFACT_BATCH_COUNT))),
85
+ batchIndex: BatchIndexSchema,
86
+ releaseId: ReleaseIdSchema,
87
+ };
88
+ /** Canonical input for one bounded immutable-artifact staging operation. */
89
+ export const StageArtifactBatchInputSchema = Schema.Struct(StageArtifactBatchFields);
90
+ /** Stages one non-empty bounded batch of immutable signed artifacts. */
91
+ export const StageArtifactBatchRequestSchema = Schema.Struct({
92
+ ...StageArtifactBatchFields,
93
+ operation: Schema.Literal("stageArtifactBatch"),
94
+ });
95
+ /** Idempotent row counts returned by one bounded staging transaction. */
96
+ export const StageBatchReceiptSchema = Schema.Struct({
97
+ batchIndex: BatchIndexSchema,
98
+ created: Schema.Finite.pipe(Schema.check(Schema.isInt()), Schema.check(Schema.isGreaterThanOrEqualTo(0))),
99
+ releaseId: ReleaseIdSchema,
100
+ unchanged: Schema.Finite.pipe(Schema.check(Schema.isInt()), Schema.check(Schema.isGreaterThanOrEqualTo(0))),
101
+ });
@@ -0,0 +1,168 @@
1
+ import { Schema } from "effect";
2
+ /** Stable rejection codes that require no message parsing by clients. */
3
+ export declare const PublicationDomainRejectionCodeSchema: Schema.Literals<readonly ["CONTENT_RELEASE_INTEGRITY", "CONTENT_RELEASE_LIMIT", "CONTENT_RELEASE_MISSING", "CONTENT_RELEASE_ROUTE", "CONTENT_RELEASE_SIZE", "CONTENT_RELEASE_STATE", "CONTENT_RELEASE_UNSUPPORTED"]>;
4
+ export type PublicationDomainRejectionCode = typeof PublicationDomainRejectionCodeSchema.Type;
5
+ /** Stable rejection codes that require no message parsing by clients. */
6
+ export declare const PublicationRejectionCodeSchema: Schema.Union<readonly [Schema.Literals<readonly ["CONTENT_RELEASE_INTEGRITY", "CONTENT_RELEASE_LIMIT", "CONTENT_RELEASE_MISSING", "CONTENT_RELEASE_ROUTE", "CONTENT_RELEASE_SIZE", "CONTENT_RELEASE_STATE", "CONTENT_RELEASE_UNSUPPORTED"]>, Schema.Literal<"CONTENT_RELEASE_INVALID_REQUEST">]>;
7
+ export type PublicationRejectionCode = typeof PublicationRejectionCodeSchema.Type;
8
+ /** Complete stable code vocabulary with one canonical HTTP status mapping. */
9
+ export declare const PublicationFailureCodeSchema: Schema.Union<readonly [Schema.Union<readonly [Schema.Literals<readonly ["CONTENT_RELEASE_INTEGRITY", "CONTENT_RELEASE_LIMIT", "CONTENT_RELEASE_MISSING", "CONTENT_RELEASE_ROUTE", "CONTENT_RELEASE_SIZE", "CONTENT_RELEASE_STATE", "CONTENT_RELEASE_UNSUPPORTED"]>, Schema.Literal<"CONTENT_RELEASE_INVALID_REQUEST">]>, Schema.Literals<readonly ["CONTENT_RELEASE_UNAUTHORIZED", "CONTENT_RELEASE_CONFLICT", "CONTENT_RELEASE_STALE_BASE"]>]>;
10
+ export type PublicationFailureCode = typeof PublicationFailureCodeSchema.Type;
11
+ /** Exact HTTP statuses returned for stable publication failures. */
12
+ export declare const PublicationFailureStatusSchema: Schema.Literals<readonly [400, 401, 404, 409, 413, 415, 422]>;
13
+ export type PublicationFailureStatus = typeof PublicationFailureStatusSchema.Type;
14
+ /** Canonical publication failure-code to HTTP-status contract. */
15
+ export declare const PUBLICATION_FAILURE_STATUSES: Readonly<{
16
+ [Code in PublicationFailureCode]: PublicationFailureStatus;
17
+ }>;
18
+ /** Resolves the exact HTTP status owned by one stable failure code. */
19
+ export declare function publicationFailureStatus(code: PublicationFailureCode): 400 | 401 | 404 | 409 | 413 | 415 | 422;
20
+ /** Authentication failed before any publication capability was invoked. */
21
+ export declare const PublicationUnauthorizedSchema: Schema.Struct<{
22
+ readonly code: Schema.Literal<"CONTENT_RELEASE_UNAUTHORIZED">;
23
+ readonly kind: Schema.Literal<"unauthorized">;
24
+ }>;
25
+ export type PublicationUnauthorized = typeof PublicationUnauthorizedSchema.Type;
26
+ /** Request body was rejected before a publication operation could be decoded. */
27
+ export declare const PublicationPredecodeRejectedSchema: Schema.Struct<{
28
+ readonly code: Schema.Literals<readonly ["CONTENT_RELEASE_SIZE", "CONTENT_RELEASE_UNSUPPORTED"]>;
29
+ readonly kind: Schema.Literal<"rejected">;
30
+ readonly operation: Schema.Null;
31
+ readonly releaseId: Schema.Null;
32
+ }>;
33
+ export type PublicationPredecodeRejected = typeof PublicationPredecodeRejectedSchema.Type;
34
+ /** One request was invalid or rejected by a stable authenticated domain rule. */
35
+ export declare const PublicationRejectedSchema: Schema.Union<readonly [Schema.Struct<{
36
+ readonly code: Schema.Literal<"CONTENT_RELEASE_INVALID_REQUEST">;
37
+ readonly kind: Schema.Literal<"rejected">;
38
+ readonly operation: Schema.Null;
39
+ readonly releaseId: Schema.Null;
40
+ }>, Schema.Struct<{
41
+ readonly code: Schema.Literals<readonly ["CONTENT_RELEASE_SIZE", "CONTENT_RELEASE_UNSUPPORTED"]>;
42
+ readonly kind: Schema.Literal<"rejected">;
43
+ readonly operation: Schema.Null;
44
+ readonly releaseId: Schema.Null;
45
+ }>, Schema.Struct<{
46
+ readonly code: Schema.Literals<readonly ["CONTENT_RELEASE_INTEGRITY", "CONTENT_RELEASE_LIMIT", "CONTENT_RELEASE_MISSING", "CONTENT_RELEASE_ROUTE", "CONTENT_RELEASE_SIZE", "CONTENT_RELEASE_STATE", "CONTENT_RELEASE_UNSUPPORTED"]>;
47
+ readonly kind: Schema.Literal<"rejected">;
48
+ readonly operation: Schema.Literals<readonly ["accept", "abort", "stageRelease", "stageRecovery", "stageSnapshot", "stageSnapshotBatch", "stageTryoutRuntimeBundle", "stageGroup", "headPage", "recovery", "stageItemBatch", "stageRouteBatch", "stageProjectionBatch", "stageArtifactBatch", "status", "verify", "activate", "activateRecovery", "rollbackPage", "routePage", "cleanup"]>;
49
+ readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
50
+ }>, Schema.Struct<{
51
+ readonly code: Schema.Literals<readonly ["CONTENT_RELEASE_INTEGRITY", "CONTENT_RELEASE_LIMIT", "CONTENT_RELEASE_MISSING", "CONTENT_RELEASE_ROUTE", "CONTENT_RELEASE_SIZE", "CONTENT_RELEASE_STATE", "CONTENT_RELEASE_UNSUPPORTED"]>;
52
+ readonly kind: Schema.Literal<"rejected">;
53
+ readonly operation: Schema.Literal<"current">;
54
+ readonly releaseId: Schema.Null;
55
+ }>]>;
56
+ export type PublicationRejected = typeof PublicationRejectedSchema.Type;
57
+ /** Immutable request identity was reused with different persisted bytes. */
58
+ export declare const PublicationConflictSchema: Schema.Union<readonly [Schema.Struct<{
59
+ readonly code: Schema.Literal<"CONTENT_RELEASE_CONFLICT">;
60
+ readonly kind: Schema.Literal<"conflict">;
61
+ readonly operation: Schema.Literals<readonly ["accept", "abort", "stageRelease", "stageRecovery", "stageGroup", "status", "verify", "activate", "activateRecovery", "rollbackPage", "routePage", "cleanup"]>;
62
+ readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
63
+ }>, Schema.Struct<{
64
+ readonly batchIndex: Schema.Finite;
65
+ readonly code: Schema.Literal<"CONTENT_RELEASE_CONFLICT">;
66
+ readonly kind: Schema.Literal<"conflict">;
67
+ readonly operation: Schema.Literals<readonly ["stageItemBatch", "stageRouteBatch", "stageProjectionBatch", "stageArtifactBatch"]>;
68
+ readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
69
+ }>, Schema.Struct<{
70
+ readonly code: Schema.Literal<"CONTENT_RELEASE_CONFLICT">;
71
+ readonly family: Schema.Literals<readonly ["program", "quran", "tryout"]>;
72
+ readonly kind: Schema.Literal<"conflict">;
73
+ readonly operation: Schema.Literal<"stageSnapshot">;
74
+ readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
75
+ readonly snapshotId: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
76
+ }>, Schema.Struct<{
77
+ readonly batchIndex: Schema.Int;
78
+ readonly code: Schema.Literal<"CONTENT_RELEASE_CONFLICT">;
79
+ readonly family: Schema.Literals<readonly ["program", "quran", "tryout"]>;
80
+ readonly kind: Schema.Literal<"conflict">;
81
+ readonly operation: Schema.Literal<"stageSnapshotBatch">;
82
+ readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
83
+ readonly snapshotId: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
84
+ }>, Schema.Struct<{
85
+ readonly bundleHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
86
+ readonly code: Schema.Literal<"CONTENT_RELEASE_CONFLICT">;
87
+ readonly kind: Schema.Literal<"conflict">;
88
+ readonly operation: Schema.Literal<"stageTryoutRuntimeBundle">;
89
+ readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
90
+ readonly snapshotId: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
91
+ }>]>;
92
+ export type PublicationConflict = typeof PublicationConflictSchema.Type;
93
+ /** Active publication state no longer matches the signed release base. */
94
+ export declare const PublicationStaleBaseSchema: Schema.Struct<{
95
+ readonly activeReleaseId: Schema.NullOr<Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">>;
96
+ readonly code: Schema.Literal<"CONTENT_RELEASE_STALE_BASE">;
97
+ readonly expectedBaseReleaseId: Schema.NullOr<Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">>;
98
+ readonly kind: Schema.Literal<"stale-base">;
99
+ readonly operation: Schema.Literals<readonly ["stageRelease", "activate"]>;
100
+ readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
101
+ }>;
102
+ export type PublicationStaleBase = typeof PublicationStaleBaseSchema.Type;
103
+ /** Complete stable publication failure vocabulary returned on the wire. */
104
+ export declare const PublicationFailureSchema: Schema.Union<readonly [Schema.Struct<{
105
+ readonly code: Schema.Literal<"CONTENT_RELEASE_UNAUTHORIZED">;
106
+ readonly kind: Schema.Literal<"unauthorized">;
107
+ }>, Schema.Union<readonly [Schema.Struct<{
108
+ readonly code: Schema.Literal<"CONTENT_RELEASE_INVALID_REQUEST">;
109
+ readonly kind: Schema.Literal<"rejected">;
110
+ readonly operation: Schema.Null;
111
+ readonly releaseId: Schema.Null;
112
+ }>, Schema.Struct<{
113
+ readonly code: Schema.Literals<readonly ["CONTENT_RELEASE_SIZE", "CONTENT_RELEASE_UNSUPPORTED"]>;
114
+ readonly kind: Schema.Literal<"rejected">;
115
+ readonly operation: Schema.Null;
116
+ readonly releaseId: Schema.Null;
117
+ }>, Schema.Struct<{
118
+ readonly code: Schema.Literals<readonly ["CONTENT_RELEASE_INTEGRITY", "CONTENT_RELEASE_LIMIT", "CONTENT_RELEASE_MISSING", "CONTENT_RELEASE_ROUTE", "CONTENT_RELEASE_SIZE", "CONTENT_RELEASE_STATE", "CONTENT_RELEASE_UNSUPPORTED"]>;
119
+ readonly kind: Schema.Literal<"rejected">;
120
+ readonly operation: Schema.Literals<readonly ["accept", "abort", "stageRelease", "stageRecovery", "stageSnapshot", "stageSnapshotBatch", "stageTryoutRuntimeBundle", "stageGroup", "headPage", "recovery", "stageItemBatch", "stageRouteBatch", "stageProjectionBatch", "stageArtifactBatch", "status", "verify", "activate", "activateRecovery", "rollbackPage", "routePage", "cleanup"]>;
121
+ readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
122
+ }>, Schema.Struct<{
123
+ readonly code: Schema.Literals<readonly ["CONTENT_RELEASE_INTEGRITY", "CONTENT_RELEASE_LIMIT", "CONTENT_RELEASE_MISSING", "CONTENT_RELEASE_ROUTE", "CONTENT_RELEASE_SIZE", "CONTENT_RELEASE_STATE", "CONTENT_RELEASE_UNSUPPORTED"]>;
124
+ readonly kind: Schema.Literal<"rejected">;
125
+ readonly operation: Schema.Literal<"current">;
126
+ readonly releaseId: Schema.Null;
127
+ }>]>, Schema.Union<readonly [Schema.Struct<{
128
+ readonly code: Schema.Literal<"CONTENT_RELEASE_CONFLICT">;
129
+ readonly kind: Schema.Literal<"conflict">;
130
+ readonly operation: Schema.Literals<readonly ["accept", "abort", "stageRelease", "stageRecovery", "stageGroup", "status", "verify", "activate", "activateRecovery", "rollbackPage", "routePage", "cleanup"]>;
131
+ readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
132
+ }>, Schema.Struct<{
133
+ readonly batchIndex: Schema.Finite;
134
+ readonly code: Schema.Literal<"CONTENT_RELEASE_CONFLICT">;
135
+ readonly kind: Schema.Literal<"conflict">;
136
+ readonly operation: Schema.Literals<readonly ["stageItemBatch", "stageRouteBatch", "stageProjectionBatch", "stageArtifactBatch"]>;
137
+ readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
138
+ }>, Schema.Struct<{
139
+ readonly code: Schema.Literal<"CONTENT_RELEASE_CONFLICT">;
140
+ readonly family: Schema.Literals<readonly ["program", "quran", "tryout"]>;
141
+ readonly kind: Schema.Literal<"conflict">;
142
+ readonly operation: Schema.Literal<"stageSnapshot">;
143
+ readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
144
+ readonly snapshotId: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
145
+ }>, Schema.Struct<{
146
+ readonly batchIndex: Schema.Int;
147
+ readonly code: Schema.Literal<"CONTENT_RELEASE_CONFLICT">;
148
+ readonly family: Schema.Literals<readonly ["program", "quran", "tryout"]>;
149
+ readonly kind: Schema.Literal<"conflict">;
150
+ readonly operation: Schema.Literal<"stageSnapshotBatch">;
151
+ readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
152
+ readonly snapshotId: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
153
+ }>, Schema.Struct<{
154
+ readonly bundleHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
155
+ readonly code: Schema.Literal<"CONTENT_RELEASE_CONFLICT">;
156
+ readonly kind: Schema.Literal<"conflict">;
157
+ readonly operation: Schema.Literal<"stageTryoutRuntimeBundle">;
158
+ readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
159
+ readonly snapshotId: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
160
+ }>]>, Schema.Struct<{
161
+ readonly activeReleaseId: Schema.NullOr<Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">>;
162
+ readonly code: Schema.Literal<"CONTENT_RELEASE_STALE_BASE">;
163
+ readonly expectedBaseReleaseId: Schema.NullOr<Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">>;
164
+ readonly kind: Schema.Literal<"stale-base">;
165
+ readonly operation: Schema.Literals<readonly ["stageRelease", "activate"]>;
166
+ readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
167
+ }>]>;
168
+ export type PublicationFailure = typeof PublicationFailureSchema.Type;
@@ -0,0 +1,194 @@
1
+ import { Schema } from "effect";
2
+ import { ReleaseIdSchema, Sha256HashSchema } from "#contracts/ids";
3
+ import { ContentSnapshotKindSchema } from "#contracts/release/snapshot/scope";
4
+ /** Stable rejection codes that require no message parsing by clients. */
5
+ export const PublicationDomainRejectionCodeSchema = Schema.Literals([
6
+ "CONTENT_RELEASE_INTEGRITY",
7
+ "CONTENT_RELEASE_LIMIT",
8
+ "CONTENT_RELEASE_MISSING",
9
+ "CONTENT_RELEASE_ROUTE",
10
+ "CONTENT_RELEASE_SIZE",
11
+ "CONTENT_RELEASE_STATE",
12
+ "CONTENT_RELEASE_UNSUPPORTED",
13
+ ]);
14
+ /** Stable rejection codes that require no message parsing by clients. */
15
+ export const PublicationRejectionCodeSchema = Schema.Union([
16
+ PublicationDomainRejectionCodeSchema,
17
+ Schema.Literal("CONTENT_RELEASE_INVALID_REQUEST"),
18
+ ]);
19
+ /** Complete stable code vocabulary with one canonical HTTP status mapping. */
20
+ export const PublicationFailureCodeSchema = Schema.Union([
21
+ PublicationRejectionCodeSchema,
22
+ Schema.Literals([
23
+ "CONTENT_RELEASE_UNAUTHORIZED",
24
+ "CONTENT_RELEASE_CONFLICT",
25
+ "CONTENT_RELEASE_STALE_BASE",
26
+ ]),
27
+ ]);
28
+ /** Exact HTTP statuses returned for stable publication failures. */
29
+ export const PublicationFailureStatusSchema = Schema.Literals([
30
+ 400, 401, 404, 409, 413, 415, 422,
31
+ ]);
32
+ /** Canonical publication failure-code to HTTP-status contract. */
33
+ export const PUBLICATION_FAILURE_STATUSES = Object.freeze({
34
+ CONTENT_RELEASE_CONFLICT: 409,
35
+ CONTENT_RELEASE_INTEGRITY: 422,
36
+ CONTENT_RELEASE_INVALID_REQUEST: 400,
37
+ CONTENT_RELEASE_LIMIT: 413,
38
+ CONTENT_RELEASE_MISSING: 404,
39
+ CONTENT_RELEASE_ROUTE: 422,
40
+ CONTENT_RELEASE_SIZE: 413,
41
+ CONTENT_RELEASE_STALE_BASE: 409,
42
+ CONTENT_RELEASE_STATE: 422,
43
+ CONTENT_RELEASE_UNAUTHORIZED: 401,
44
+ CONTENT_RELEASE_UNSUPPORTED: 415,
45
+ });
46
+ /** Resolves the exact HTTP status owned by one stable failure code. */
47
+ export function publicationFailureStatus(code) {
48
+ return PUBLICATION_FAILURE_STATUSES[code];
49
+ }
50
+ /** Authentication failed before any publication capability was invoked. */
51
+ export const PublicationUnauthorizedSchema = Schema.Struct({
52
+ code: Schema.Literal("CONTENT_RELEASE_UNAUTHORIZED"),
53
+ kind: Schema.Literal("unauthorized"),
54
+ });
55
+ const PublicationInvalidRequestSchema = Schema.Struct({
56
+ code: Schema.Literal("CONTENT_RELEASE_INVALID_REQUEST"),
57
+ kind: Schema.Literal("rejected"),
58
+ operation: Schema.Null,
59
+ releaseId: Schema.Null,
60
+ });
61
+ /** Request body was rejected before a publication operation could be decoded. */
62
+ export const PublicationPredecodeRejectedSchema = Schema.Struct({
63
+ code: Schema.Literals([
64
+ "CONTENT_RELEASE_SIZE",
65
+ "CONTENT_RELEASE_UNSUPPORTED",
66
+ ]),
67
+ kind: Schema.Literal("rejected"),
68
+ operation: Schema.Null,
69
+ releaseId: Schema.Null,
70
+ });
71
+ const PublicationReleaseRejectedSchema = Schema.Struct({
72
+ code: PublicationDomainRejectionCodeSchema,
73
+ kind: Schema.Literal("rejected"),
74
+ operation: Schema.Literals([
75
+ "accept",
76
+ "abort",
77
+ "stageRelease",
78
+ "stageRecovery",
79
+ "stageSnapshot",
80
+ "stageSnapshotBatch",
81
+ "stageTryoutRuntimeBundle",
82
+ "stageGroup",
83
+ "headPage",
84
+ "recovery",
85
+ "stageItemBatch",
86
+ "stageRouteBatch",
87
+ "stageProjectionBatch",
88
+ "stageArtifactBatch",
89
+ "status",
90
+ "verify",
91
+ "activate",
92
+ "activateRecovery",
93
+ "rollbackPage",
94
+ "routePage",
95
+ "cleanup",
96
+ ]),
97
+ releaseId: ReleaseIdSchema,
98
+ });
99
+ const PublicationCurrentRejectedSchema = Schema.Struct({
100
+ code: PublicationDomainRejectionCodeSchema,
101
+ kind: Schema.Literal("rejected"),
102
+ operation: Schema.Literal("current"),
103
+ releaseId: Schema.Null,
104
+ });
105
+ /** One request was invalid or rejected by a stable authenticated domain rule. */
106
+ export const PublicationRejectedSchema = Schema.Union([
107
+ PublicationInvalidRequestSchema,
108
+ PublicationPredecodeRejectedSchema,
109
+ PublicationReleaseRejectedSchema,
110
+ PublicationCurrentRejectedSchema,
111
+ ]);
112
+ const ReleaseConflictSchema = Schema.Struct({
113
+ code: Schema.Literal("CONTENT_RELEASE_CONFLICT"),
114
+ kind: Schema.Literal("conflict"),
115
+ operation: Schema.Literals([
116
+ "accept",
117
+ "abort",
118
+ "stageRelease",
119
+ "stageRecovery",
120
+ "stageGroup",
121
+ "status",
122
+ "verify",
123
+ "activate",
124
+ "activateRecovery",
125
+ "rollbackPage",
126
+ "routePage",
127
+ "cleanup",
128
+ ]),
129
+ releaseId: ReleaseIdSchema,
130
+ });
131
+ const BatchConflictSchema = Schema.Struct({
132
+ batchIndex: Schema.Finite.pipe(Schema.check(Schema.isInt()), Schema.check(Schema.isGreaterThanOrEqualTo(0))),
133
+ code: Schema.Literal("CONTENT_RELEASE_CONFLICT"),
134
+ kind: Schema.Literal("conflict"),
135
+ operation: Schema.Literals([
136
+ "stageItemBatch",
137
+ "stageRouteBatch",
138
+ "stageProjectionBatch",
139
+ "stageArtifactBatch",
140
+ ]),
141
+ releaseId: ReleaseIdSchema,
142
+ });
143
+ const SnapshotManifestConflictSchema = Schema.Struct({
144
+ code: Schema.Literal("CONTENT_RELEASE_CONFLICT"),
145
+ family: ContentSnapshotKindSchema,
146
+ kind: Schema.Literal("conflict"),
147
+ operation: Schema.Literal("stageSnapshot"),
148
+ releaseId: ReleaseIdSchema,
149
+ snapshotId: Sha256HashSchema,
150
+ });
151
+ const SnapshotBatchConflictSchema = Schema.Struct({
152
+ batchIndex: Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0))),
153
+ code: Schema.Literal("CONTENT_RELEASE_CONFLICT"),
154
+ family: ContentSnapshotKindSchema,
155
+ kind: Schema.Literal("conflict"),
156
+ operation: Schema.Literal("stageSnapshotBatch"),
157
+ releaseId: ReleaseIdSchema,
158
+ snapshotId: Sha256HashSchema,
159
+ });
160
+ const TryoutRuntimeBundleConflictSchema = Schema.Struct({
161
+ bundleHash: Sha256HashSchema,
162
+ code: Schema.Literal("CONTENT_RELEASE_CONFLICT"),
163
+ kind: Schema.Literal("conflict"),
164
+ operation: Schema.Literal("stageTryoutRuntimeBundle"),
165
+ releaseId: ReleaseIdSchema,
166
+ snapshotId: Sha256HashSchema,
167
+ });
168
+ /** Immutable request identity was reused with different persisted bytes. */
169
+ export const PublicationConflictSchema = Schema.Union([
170
+ ReleaseConflictSchema,
171
+ BatchConflictSchema,
172
+ SnapshotManifestConflictSchema,
173
+ SnapshotBatchConflictSchema,
174
+ TryoutRuntimeBundleConflictSchema,
175
+ ]);
176
+ /** Active publication state no longer matches the signed release base. */
177
+ export const PublicationStaleBaseSchema = Schema.Struct({
178
+ activeReleaseId: Schema.NullOr(ReleaseIdSchema),
179
+ code: Schema.Literal("CONTENT_RELEASE_STALE_BASE"),
180
+ expectedBaseReleaseId: Schema.NullOr(ReleaseIdSchema),
181
+ kind: Schema.Literal("stale-base"),
182
+ operation: Schema.Literals(["stageRelease", "activate"]),
183
+ releaseId: ReleaseIdSchema,
184
+ }).pipe(Schema.check(Schema.makeFilter(({ activeReleaseId, expectedBaseReleaseId, releaseId }) => activeReleaseId !== expectedBaseReleaseId &&
185
+ activeReleaseId !== releaseId, {
186
+ message: "Expected the active release to differ from the requested base and candidate.",
187
+ })));
188
+ /** Complete stable publication failure vocabulary returned on the wire. */
189
+ export const PublicationFailureSchema = Schema.Union([
190
+ PublicationUnauthorizedSchema,
191
+ PublicationRejectedSchema,
192
+ PublicationConflictSchema,
193
+ PublicationStaleBaseSchema,
194
+ ]);