@parrel/ledger 0.0.0-stage → 5.0.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 (239) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +793 -2
  3. package/dist/cli/commands.d.ts +51 -0
  4. package/dist/cli/commands.d.ts.map +1 -0
  5. package/dist/cli/commands.js +968 -0
  6. package/dist/cli/commands.js.map +1 -0
  7. package/dist/cli/index.d.ts +24 -0
  8. package/dist/cli/index.d.ts.map +1 -0
  9. package/dist/cli/index.js +35 -0
  10. package/dist/cli/index.js.map +1 -0
  11. package/dist/cli/parrel.d.ts +3 -0
  12. package/dist/cli/parrel.d.ts.map +1 -0
  13. package/dist/cli/parrel.js +5 -0
  14. package/dist/cli/parrel.js.map +1 -0
  15. package/dist/cli/utils/angular-setup.d.ts +14 -0
  16. package/dist/cli/utils/angular-setup.d.ts.map +1 -0
  17. package/dist/cli/utils/angular-setup.js +96 -0
  18. package/dist/cli/utils/angular-setup.js.map +1 -0
  19. package/dist/cli/utils/api-tree-builder.d.ts +24 -0
  20. package/dist/cli/utils/api-tree-builder.d.ts.map +1 -0
  21. package/dist/cli/utils/api-tree-builder.js +146 -0
  22. package/dist/cli/utils/api-tree-builder.js.map +1 -0
  23. package/dist/cli/utils/bundle-reader.d.ts +185 -0
  24. package/dist/cli/utils/bundle-reader.d.ts.map +1 -0
  25. package/dist/cli/utils/bundle-reader.js +518 -0
  26. package/dist/cli/utils/bundle-reader.js.map +1 -0
  27. package/dist/cli/utils/collision-detector.d.ts +21 -0
  28. package/dist/cli/utils/collision-detector.d.ts.map +1 -0
  29. package/dist/cli/utils/collision-detector.js +53 -0
  30. package/dist/cli/utils/collision-detector.js.map +1 -0
  31. package/dist/cli/utils/map-fields.d.ts +42 -0
  32. package/dist/cli/utils/map-fields.d.ts.map +1 -0
  33. package/dist/cli/utils/map-fields.js +90 -0
  34. package/dist/cli/utils/map-fields.js.map +1 -0
  35. package/dist/cli/utils/map-validator.d.ts +42 -0
  36. package/dist/cli/utils/map-validator.d.ts.map +1 -0
  37. package/dist/cli/utils/map-validator.js +119 -0
  38. package/dist/cli/utils/map-validator.js.map +1 -0
  39. package/dist/cli/utils/media-file.d.ts +41 -0
  40. package/dist/cli/utils/media-file.d.ts.map +1 -0
  41. package/dist/cli/utils/media-file.js +72 -0
  42. package/dist/cli/utils/media-file.js.map +1 -0
  43. package/dist/cli/utils/media-validator.d.ts +10 -0
  44. package/dist/cli/utils/media-validator.d.ts.map +1 -0
  45. package/dist/cli/utils/media-validator.js +85 -0
  46. package/dist/cli/utils/media-validator.js.map +1 -0
  47. package/dist/cli/utils/mock-augmenter.d.ts +19 -0
  48. package/dist/cli/utils/mock-augmenter.d.ts.map +1 -0
  49. package/dist/cli/utils/mock-augmenter.js +102 -0
  50. package/dist/cli/utils/mock-augmenter.js.map +1 -0
  51. package/dist/cli/utils/mock-validator.d.ts +27 -0
  52. package/dist/cli/utils/mock-validator.d.ts.map +1 -0
  53. package/dist/cli/utils/mock-validator.js +214 -0
  54. package/dist/cli/utils/mock-validator.js.map +1 -0
  55. package/dist/cli/utils/project-dir.d.ts +24 -0
  56. package/dist/cli/utils/project-dir.d.ts.map +1 -0
  57. package/dist/cli/utils/project-dir.js +32 -0
  58. package/dist/cli/utils/project-dir.js.map +1 -0
  59. package/dist/cli/utils/schema-loader.d.ts +19 -0
  60. package/dist/cli/utils/schema-loader.d.ts.map +1 -0
  61. package/dist/cli/utils/schema-loader.js +101 -0
  62. package/dist/cli/utils/schema-loader.js.map +1 -0
  63. package/dist/cli/utils/server-entry.d.ts +34 -0
  64. package/dist/cli/utils/server-entry.d.ts.map +1 -0
  65. package/dist/cli/utils/server-entry.js +111 -0
  66. package/dist/cli/utils/server-entry.js.map +1 -0
  67. package/dist/cli/utils/sync.d.ts +116 -0
  68. package/dist/cli/utils/sync.d.ts.map +1 -0
  69. package/dist/cli/utils/sync.js +134 -0
  70. package/dist/cli/utils/sync.js.map +1 -0
  71. package/dist/client/index.d.ts +39 -0
  72. package/dist/client/index.d.ts.map +1 -0
  73. package/dist/client/index.js +88 -0
  74. package/dist/client/index.js.map +1 -0
  75. package/dist/core/browser-session.d.ts +5 -0
  76. package/dist/core/browser-session.d.ts.map +1 -0
  77. package/dist/core/browser-session.js +12 -0
  78. package/dist/core/browser-session.js.map +1 -0
  79. package/dist/core/cache.d.ts +80 -0
  80. package/dist/core/cache.d.ts.map +1 -0
  81. package/dist/core/cache.js +95 -0
  82. package/dist/core/cache.js.map +1 -0
  83. package/dist/core/client.d.ts +64 -0
  84. package/dist/core/client.d.ts.map +1 -0
  85. package/dist/core/client.js +281 -0
  86. package/dist/core/client.js.map +1 -0
  87. package/dist/core/config.d.ts +20 -0
  88. package/dist/core/config.d.ts.map +1 -0
  89. package/dist/core/config.js +32 -0
  90. package/dist/core/config.js.map +1 -0
  91. package/dist/core/copy-read.d.ts +25 -0
  92. package/dist/core/copy-read.d.ts.map +1 -0
  93. package/dist/core/copy-read.js +123 -0
  94. package/dist/core/copy-read.js.map +1 -0
  95. package/dist/core/define-ledger.d.ts +38 -0
  96. package/dist/core/define-ledger.d.ts.map +1 -0
  97. package/dist/core/define-ledger.js +65 -0
  98. package/dist/core/define-ledger.js.map +1 -0
  99. package/dist/core/deprecated.d.ts +16 -0
  100. package/dist/core/deprecated.d.ts.map +1 -0
  101. package/dist/core/deprecated.js +14 -0
  102. package/dist/core/deprecated.js.map +1 -0
  103. package/dist/core/env.d.ts +103 -0
  104. package/dist/core/env.d.ts.map +1 -0
  105. package/dist/core/env.js +208 -0
  106. package/dist/core/env.js.map +1 -0
  107. package/dist/core/error-codes.generated.d.ts +12 -0
  108. package/dist/core/error-codes.generated.d.ts.map +1 -0
  109. package/dist/core/error-codes.generated.js +3 -0
  110. package/dist/core/error-codes.generated.js.map +1 -0
  111. package/dist/core/get-content.d.ts +62 -0
  112. package/dist/core/get-content.d.ts.map +1 -0
  113. package/dist/core/get-content.js +86 -0
  114. package/dist/core/get-content.js.map +1 -0
  115. package/dist/core/get-media.d.ts +58 -0
  116. package/dist/core/get-media.d.ts.map +1 -0
  117. package/dist/core/get-media.js +89 -0
  118. package/dist/core/get-media.js.map +1 -0
  119. package/dist/core/manifest.d.ts +38 -0
  120. package/dist/core/manifest.d.ts.map +1 -0
  121. package/dist/core/manifest.js +93 -0
  122. package/dist/core/manifest.js.map +1 -0
  123. package/dist/core/media-proxy.d.ts +41 -0
  124. package/dist/core/media-proxy.d.ts.map +1 -0
  125. package/dist/core/media-proxy.js +219 -0
  126. package/dist/core/media-proxy.js.map +1 -0
  127. package/dist/core/package-info.d.ts +34 -0
  128. package/dist/core/package-info.d.ts.map +1 -0
  129. package/dist/core/package-info.js +39 -0
  130. package/dist/core/package-info.js.map +1 -0
  131. package/dist/core/parrel-error.d.ts +160 -0
  132. package/dist/core/parrel-error.d.ts.map +1 -0
  133. package/dist/core/parrel-error.js +198 -0
  134. package/dist/core/parrel-error.js.map +1 -0
  135. package/dist/core/transform-content.d.ts +42 -0
  136. package/dist/core/transform-content.d.ts.map +1 -0
  137. package/dist/core/transform-content.js +185 -0
  138. package/dist/core/transform-content.js.map +1 -0
  139. package/dist/core/types.d.ts +406 -0
  140. package/dist/core/types.d.ts.map +1 -0
  141. package/dist/core/types.js +11 -0
  142. package/dist/core/types.js.map +1 -0
  143. package/dist/errors/error-messages.generated.d.ts +5 -0
  144. package/dist/errors/error-messages.generated.d.ts.map +1 -0
  145. package/dist/errors/error-messages.generated.js +971 -0
  146. package/dist/errors/error-messages.generated.js.map +1 -0
  147. package/dist/errors/get-error-info.d.ts +29 -0
  148. package/dist/errors/get-error-info.d.ts.map +1 -0
  149. package/dist/errors/get-error-info.js +43 -0
  150. package/dist/errors/get-error-info.js.map +1 -0
  151. package/dist/errors/index.d.ts +4 -0
  152. package/dist/errors/index.d.ts.map +1 -0
  153. package/dist/errors/index.js +4 -0
  154. package/dist/errors/index.js.map +1 -0
  155. package/dist/errors/types.d.ts +19 -0
  156. package/dist/errors/types.d.ts.map +1 -0
  157. package/dist/errors/types.js +2 -0
  158. package/dist/errors/types.js.map +1 -0
  159. package/dist/generated.d.ts +29 -0
  160. package/dist/generated.d.ts.map +1 -0
  161. package/dist/generated.js +29 -0
  162. package/dist/generated.js.map +1 -0
  163. package/dist/index.d.ts +19 -0
  164. package/dist/index.d.ts.map +1 -0
  165. package/dist/index.js +16 -0
  166. package/dist/index.js.map +1 -0
  167. package/dist/mock/dev-media.d.ts +15 -0
  168. package/dist/mock/dev-media.d.ts.map +1 -0
  169. package/dist/mock/dev-media.js +52 -0
  170. package/dist/mock/dev-media.js.map +1 -0
  171. package/dist/mock/file-store.d.ts +44 -0
  172. package/dist/mock/file-store.d.ts.map +1 -0
  173. package/dist/mock/file-store.js +170 -0
  174. package/dist/mock/file-store.js.map +1 -0
  175. package/dist/mock/index.d.ts +4 -0
  176. package/dist/mock/index.d.ts.map +1 -0
  177. package/dist/mock/index.js +3 -0
  178. package/dist/mock/index.js.map +1 -0
  179. package/dist/mock/media-fields.d.ts +25 -0
  180. package/dist/mock/media-fields.d.ts.map +1 -0
  181. package/dist/mock/media-fields.js +54 -0
  182. package/dist/mock/media-fields.js.map +1 -0
  183. package/dist/mock/mock-adapter.d.ts +65 -0
  184. package/dist/mock/mock-adapter.d.ts.map +1 -0
  185. package/dist/mock/mock-adapter.js +431 -0
  186. package/dist/mock/mock-adapter.js.map +1 -0
  187. package/dist/mock/mock-errors.d.ts +18 -0
  188. package/dist/mock/mock-errors.d.ts.map +1 -0
  189. package/dist/mock/mock-errors.js +56 -0
  190. package/dist/mock/mock-errors.js.map +1 -0
  191. package/dist/mock/node-import.d.ts +13 -0
  192. package/dist/mock/node-import.d.ts.map +1 -0
  193. package/dist/mock/node-import.js +16 -0
  194. package/dist/mock/node-import.js.map +1 -0
  195. package/dist/mock/seed-mock-store.d.ts +14 -0
  196. package/dist/mock/seed-mock-store.d.ts.map +1 -0
  197. package/dist/mock/seed-mock-store.js +106 -0
  198. package/dist/mock/seed-mock-store.js.map +1 -0
  199. package/dist/mock/shared-memory-store.d.ts +35 -0
  200. package/dist/mock/shared-memory-store.d.ts.map +1 -0
  201. package/dist/mock/shared-memory-store.js +46 -0
  202. package/dist/mock/shared-memory-store.js.map +1 -0
  203. package/dist/next/dev-rendering-helpers.d.ts +78 -0
  204. package/dist/next/dev-rendering-helpers.d.ts.map +1 -0
  205. package/dist/next/dev-rendering-helpers.js +103 -0
  206. package/dist/next/dev-rendering-helpers.js.map +1 -0
  207. package/dist/next/index.d.ts +35 -0
  208. package/dist/next/index.d.ts.map +1 -0
  209. package/dist/next/index.js +33 -0
  210. package/dist/next/index.js.map +1 -0
  211. package/dist/next/next-cache-adapter.d.ts +11 -0
  212. package/dist/next/next-cache-adapter.d.ts.map +1 -0
  213. package/dist/next/next-cache-adapter.js +12 -0
  214. package/dist/next/next-cache-adapter.js.map +1 -0
  215. package/dist/nuxt/index.d.ts +22 -0
  216. package/dist/nuxt/index.d.ts.map +1 -0
  217. package/dist/nuxt/index.js +57 -0
  218. package/dist/nuxt/index.js.map +1 -0
  219. package/dist/sveltekit/index.d.ts +35 -0
  220. package/dist/sveltekit/index.d.ts.map +1 -0
  221. package/dist/sveltekit/index.js +56 -0
  222. package/dist/sveltekit/index.js.map +1 -0
  223. package/dist/ui/content-editor.d.ts +9 -0
  224. package/dist/ui/content-editor.d.ts.map +1 -0
  225. package/dist/ui/content-editor.js +27 -0
  226. package/dist/ui/content-editor.js.map +1 -0
  227. package/dist/ui/index.d.ts +8 -0
  228. package/dist/ui/index.d.ts.map +1 -0
  229. package/dist/ui/index.js +8 -0
  230. package/dist/ui/index.js.map +1 -0
  231. package/dist/ui/ledger-overlay.d.ts +10 -0
  232. package/dist/ui/ledger-overlay.d.ts.map +1 -0
  233. package/dist/ui/ledger-overlay.js +27 -0
  234. package/dist/ui/ledger-overlay.js.map +1 -0
  235. package/dist/ui/media-uploader.d.ts +9 -0
  236. package/dist/ui/media-uploader.d.ts.map +1 -0
  237. package/dist/ui/media-uploader.js +27 -0
  238. package/dist/ui/media-uploader.js.map +1 -0
  239. package/package.json +134 -6
@@ -0,0 +1,123 @@
1
+ import { LedgerCache, copyTimes } from "./cache.js";
2
+ import { ManifestCache, resourceHash } from "./manifest.js";
3
+ /**
4
+ * The read rule of rulebook LIM-13, shared by `getContent` and `getMedia`. A copy is fresh for `ttlSeconds` after it
5
+ * was downloaded or checked, and is then returned without any request. After that the manifest is read (one read
6
+ * serves every copy for `manifestTtlSeconds`) and the hash of the resource is compared: unchanged, the copy is fresh
7
+ * again; changed, it is downloaded again. A copy is downloaded again at the latest `maxAgeSeconds` after its download.
8
+ * Without a usable manifest a copy is downloaded again when it is no longer fresh (the plain TTL).
9
+ */
10
+ /** Reads of the same key that are running, so calls at the same moment share one download. */
11
+ const pendingReads = new Map();
12
+ /** The resource name of a content path: the text before the first `.` or `[`. */
13
+ export function resourceOf(path) {
14
+ const end = path.search(/[.[]/);
15
+ return end < 0 ? path : path.slice(0, end);
16
+ }
17
+ /**
18
+ * The resource that holds a media path, the way the server adapter splits it: `homepage.hero` and `homepage-hero` both
19
+ * belong to `homepage`. A media URL follows the hash of that resource, because the manifest lists media by file name.
20
+ */
21
+ export function mediaResourceOf(path) {
22
+ if (/[.[]/.test(path))
23
+ return resourceOf(path);
24
+ const dash = path.lastIndexOf("-");
25
+ return dash > 0 && dash < path.length - 1 ? path.slice(0, dash) : path;
26
+ }
27
+ /**
28
+ * The manifest of the service, read at most once per `manifestTtlSeconds`. `null` when the adapter has no manifest or
29
+ * cannot read it: the caller then falls back to the plain TTL.
30
+ */
31
+ async function readManifest(config, times) {
32
+ const getManifest = config.adapter.getManifest;
33
+ if (!getManifest)
34
+ return null;
35
+ try {
36
+ return await ManifestCache.getManifest(() => getManifest.call(config.adapter), {
37
+ key: config.slug,
38
+ ttlSeconds: times.manifestTtlSeconds,
39
+ });
40
+ }
41
+ catch {
42
+ return null;
43
+ }
44
+ }
45
+ /** The hash of `resource` in the manifest that is in memory, without a request. */
46
+ function hashInMemory(config, resource) {
47
+ const manifest = ManifestCache.get(config.slug);
48
+ return manifest ? resourceHash(manifest, resource) : undefined;
49
+ }
50
+ /** Reads `key` by the rule of rulebook LIM-13 and the cache mode of `options`. */
51
+ export async function readWithCopy({ config, key, resource, options, download }) {
52
+ const mode = options?.cache ?? "default";
53
+ if (config.cache?.enabled === false || mode === "no-store") {
54
+ return download(options);
55
+ }
56
+ const times = copyTimes(config);
57
+ if (mode === "force") {
58
+ const value = await download(options);
59
+ LedgerCache.setCopy(key, value, hashInMemory(config, resource), times.maxAgeSeconds);
60
+ return value;
61
+ }
62
+ const running = pendingReads.get(key);
63
+ if (running)
64
+ return running;
65
+ let fetchOptions = options;
66
+ const stored = LedgerCache.getCopy(key);
67
+ // A copy of `null` or `undefined` is no answer to keep: it is read again.
68
+ const copy = stored && stored.value !== null && stored.value !== undefined ? stored : null;
69
+ const now = Date.now();
70
+ const fresh = copy !== null && now - copy.checkedAt < times.ttlSeconds * 1000;
71
+ const tooOld = copy !== null && now - copy.downloadedAt >= times.maxAgeSeconds * 1000;
72
+ if (copy && fresh && !tooOld) {
73
+ return copy.value;
74
+ }
75
+ // One read of the manifest serves every copy within manifestTtlSeconds. A copy that is downloaded now gets the hash
76
+ // of the resource in it, so the next check can compare. A manifest that cannot be read gives no hash.
77
+ const manifest = await readManifest(config, times);
78
+ const hash = manifest ? resourceHash(manifest, resource) : undefined;
79
+ if (copy && !tooOld) {
80
+ if (hash !== undefined && hash === copy.hash) {
81
+ LedgerCache.markChecked(key);
82
+ return copy.value;
83
+ }
84
+ // The hash changed: the copy that Next.js or the browser keeps of the old answer must not be used.
85
+ if (hash !== undefined)
86
+ fetchOptions = { ...options, cache: "force" };
87
+ }
88
+ else if (copy) {
89
+ // Older than the age limit: download again, also when the hash is the same.
90
+ fetchOptions = { ...options, cache: "force" };
91
+ }
92
+ const pending = pendingReads.get(key);
93
+ if (pending)
94
+ return pending;
95
+ const read = (async () => {
96
+ const value = await download(fetchOptions);
97
+ LedgerCache.setCopy(key, value, hash, times.maxAgeSeconds);
98
+ return value;
99
+ })();
100
+ pendingReads.set(key, read);
101
+ try {
102
+ return await read;
103
+ }
104
+ finally {
105
+ pendingReads.delete(key);
106
+ }
107
+ }
108
+ /**
109
+ * Drops the copies that a write to `path` makes old: every copy of content and every copy of a media URL of the same
110
+ * resource. The manifest stays.
111
+ */
112
+ export function dropCopiesOfResource(slug, resource) {
113
+ const contentPrefix = `cms-content:${slug}:`;
114
+ const mediaPrefix = `cms-media:${slug}:`;
115
+ LedgerCache.invalidateWhere((key) => {
116
+ if (key.startsWith(contentPrefix))
117
+ return resourceOf(key.slice(contentPrefix.length)) === resource;
118
+ if (key.startsWith(mediaPrefix))
119
+ return mediaResourceOf(key.slice(mediaPrefix.length)) === resource;
120
+ return false;
121
+ });
122
+ }
123
+ //# sourceMappingURL=copy-read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy-read.js","sourceRoot":"","sources":["../../src/core/copy-read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAkB,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG5D;;;;;;GAMG;AAEH,8FAA8F;AAC9F,MAAM,YAAY,GAAG,IAAI,GAAG,EAA4B,CAAC;AAEzD,iFAAiF;AACjF,MAAM,UAAU,UAAU,CAAC,IAAY;IACtC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAChC,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC5C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC3C,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;IAC/C,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AC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY,EAAE,QAAgB;IAClE,MAAM,aAAa,GAAG,eAAe,IAAI,GAAG,CAAC;IAC7C,MAAM,WAAW,GAAG,aAAa,IAAI,GAAG,CAAC;IACzC,WAAW,CAAC,eAAe,CAAC,CAAC,GAAG,EAAE,EAAE;QACnC,IAAI,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC;YAAE,OAAO,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,KAAK,QAAQ,CAAC;QACnG,IAAI,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC;YAAE,OAAO,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,KAAK,QAAQ,CAAC;QACpG,OAAO,KAAK,CAAC;IACd,CAAC,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { DefineParrelLedgerConfig } from "./types.js";
2
+ /**
3
+ * Registers the global Parrel Ledger configuration.
4
+ *
5
+ * The configuration is stored as a singleton and reused by all runtime helpers
6
+ * such as `getContent`, `uploadContent`, and related functions.
7
+ *
8
+ * In development and tests the file-based mock adapter is used (content from
9
+ * `parrel/ledger/mock.json`); in production every call goes to the Ledger service. An app that runs only in a browser
10
+ * (React, Vue, Angular) cannot read files: pass the content as `mockData` and the mock keeps it in memory. Set `apiOrigin` (or
11
+ * `PARREL_API_ORIGIN`) to talk to a local backend, and `mode: "live"` (or `PARREL_FORCE_LIVE=1`) to use it
12
+ * in development too.
13
+ *
14
+ * @param config The Ledger configuration object
15
+ * @returns The same config object (for chaining)
16
+ * @throws {ParrelError} `SD00100002` if `config` is missing
17
+ * @throws {ParrelError} `SD00100003` if `slug` is not a non-empty string
18
+ * @throws {ParrelError} `SD00100008` when `apiOrigin` is not an allowed origin
19
+ * @throws {ParrelError} `SD00100018` when `siteOrigin` is not an origin in the accepted form
20
+ *
21
+ * In a browser without `mockData`, `defineParrelLedger` still returns; the first call of `getContent`, `getMedia`
22
+ * and the other functions throws `SD06000007`.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * // lib/ledger.ts (server-side)
27
+ * import { defineParrelLedger } from "@parrel/ledger";
28
+ *
29
+ * export const ledger = defineParrelLedger({
30
+ * slug: "your-service-slug",
31
+ * mediaProxyPath: "/api/cms-media",
32
+ * apiOrigin: process.env.PARREL_API_ORIGIN, // optional: a local backend such as http://localhost:18700
33
+ * siteOrigin: "https://shop.be", // for reads from a server; or set PARREL_SITE_ORIGIN
34
+ * });
35
+ * ```
36
+ */
37
+ export declare function defineParrelLedger(config: DefineParrelLedgerConfig): DefineParrelLedgerConfig;
38
+ //# sourceMappingURL=define-ledger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-ledger.d.ts","sourceRoot":"","sources":["../../src/core/define-ledger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAK3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,wBAAwB,CAkC7F"}
@@ -0,0 +1,65 @@
1
+ import { setParrelLedgerConfig } from "./config.js";
2
+ import { assertParrelApiOrigin, assertParrelSiteOrigin } from "./env.js";
3
+ import { ParrelError } from "./parrel-error.js";
4
+ import { mockAdapterByEnv } from "../mock/mock-adapter.js";
5
+ /**
6
+ * Registers the global Parrel Ledger configuration.
7
+ *
8
+ * The configuration is stored as a singleton and reused by all runtime helpers
9
+ * such as `getContent`, `uploadContent`, and related functions.
10
+ *
11
+ * In development and tests the file-based mock adapter is used (content from
12
+ * `parrel/ledger/mock.json`); in production every call goes to the Ledger service. An app that runs only in a browser
13
+ * (React, Vue, Angular) cannot read files: pass the content as `mockData` and the mock keeps it in memory. Set `apiOrigin` (or
14
+ * `PARREL_API_ORIGIN`) to talk to a local backend, and `mode: "live"` (or `PARREL_FORCE_LIVE=1`) to use it
15
+ * in development too.
16
+ *
17
+ * @param config The Ledger configuration object
18
+ * @returns The same config object (for chaining)
19
+ * @throws {ParrelError} `SD00100002` if `config` is missing
20
+ * @throws {ParrelError} `SD00100003` if `slug` is not a non-empty string
21
+ * @throws {ParrelError} `SD00100008` when `apiOrigin` is not an allowed origin
22
+ * @throws {ParrelError} `SD00100018` when `siteOrigin` is not an origin in the accepted form
23
+ *
24
+ * In a browser without `mockData`, `defineParrelLedger` still returns; the first call of `getContent`, `getMedia`
25
+ * and the other functions throws `SD06000007`.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * // lib/ledger.ts (server-side)
30
+ * import { defineParrelLedger } from "@parrel/ledger";
31
+ *
32
+ * export const ledger = defineParrelLedger({
33
+ * slug: "your-service-slug",
34
+ * mediaProxyPath: "/api/cms-media",
35
+ * apiOrigin: process.env.PARREL_API_ORIGIN, // optional: a local backend such as http://localhost:18700
36
+ * siteOrigin: "https://shop.be", // for reads from a server; or set PARREL_SITE_ORIGIN
37
+ * });
38
+ * ```
39
+ */
40
+ export function defineParrelLedger(config) {
41
+ if (!config) {
42
+ throw new ParrelError("SD00100002", 'The Ledger configuration is required. Pass a config object to defineParrelLedger, for example defineParrelLedger({ slug: "your-service-slug" }).');
43
+ }
44
+ if (!config.slug || typeof config.slug !== "string" || config.slug.trim() === "") {
45
+ throw new ParrelError("SD00100003", "The Ledger slug must be a non-empty string. Set `slug` in defineParrelLedger to the slug of your Ledger service, which you can copy from the Parrel portal.");
46
+ }
47
+ // A wrong apiOrigin or siteOrigin fails here, not on the first request in production.
48
+ assertParrelApiOrigin(config.apiOrigin);
49
+ assertParrelSiteOrigin(config.siteOrigin);
50
+ const adapter = mockAdapterByEnv({
51
+ file: config.mockDataDir,
52
+ data: config.mockData,
53
+ mockMediaPath: config.mockMediaPath,
54
+ apiOrigin: config.apiOrigin,
55
+ siteOrigin: config.siteOrigin,
56
+ mode: config.mode,
57
+ sendHandshakeFromBrowser: config.sendHandshakeFromBrowser,
58
+ });
59
+ setParrelLedgerConfig({
60
+ ...config,
61
+ adapter,
62
+ });
63
+ return config;
64
+ }
65
+ //# sourceMappingURL=define-ledger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-ledger.js","sourceRoot":"","sources":["../../src/core/define-ledger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAgC;IAClE,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,MAAM,IAAI,WAAW,CACpB,YAAY,EACZ,kJAAkJ,CAClJ,CAAC;IACH,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAClF,MAAM,IAAI,WAAW,CACpB,YAAY,EACZ,6JAA6J,CAC7J,CAAC;IACH,CAAC;IAED,sFAAsF;IACtF,qBAAqB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACxC,sBAAsB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAE1C,MAAM,OAAO,GAAG,gBAAgB,CAAC;QAChC,IAAI,EAAE,MAAM,CAAC,WAAW;QACxB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,wBAAwB,EAAE,MAAM,CAAC,wBAAwB;KACzD,CAAC,CAAC;IAEH,qBAAqB,CAAC;QACrB,GAAG,MAAM;QACT,OAAO;KACP,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AACf,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Runtime names from `@parrel/cms`, kept as deprecated aliases of the Ledger
3
+ * names for one major version. Type aliases live in `types.ts`.
4
+ */
5
+ import { LedgerCache } from "./cache.js";
6
+ import { createParrelLedgerServerAdapter } from "./client.js";
7
+ import { defineParrelLedger } from "./define-ledger.js";
8
+ /** @deprecated Use {@link defineParrelLedger}. Removed in the next major version. */
9
+ export declare const defineParrelCms: typeof defineParrelLedger;
10
+ /** @deprecated Use {@link createParrelLedgerServerAdapter}. Removed in the next major version. */
11
+ export declare const createParrelCmsServerAdapter: typeof createParrelLedgerServerAdapter;
12
+ /** @deprecated Use {@link LedgerCache}. Removed in the next major version. */
13
+ export declare const CmsCache: typeof LedgerCache;
14
+ /** @deprecated Use {@link LedgerCache}. Removed in the next major version. */
15
+ export type CmsCache = LedgerCache;
16
+ //# sourceMappingURL=deprecated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deprecated.d.ts","sourceRoot":"","sources":["../../src/core/deprecated.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,qFAAqF;AACrF,eAAO,MAAM,eAAe,2BAAqB,CAAC;AAElD,kGAAkG;AAClG,eAAO,MAAM,4BAA4B,wCAAkC,CAAC;AAE5E,8EAA8E;AAC9E,eAAO,MAAM,QAAQ,oBAAc,CAAC;AACpC,8EAA8E;AAC9E,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Runtime names from `@parrel/cms`, kept as deprecated aliases of the Ledger
3
+ * names for one major version. Type aliases live in `types.ts`.
4
+ */
5
+ import { LedgerCache } from "./cache.js";
6
+ import { createParrelLedgerServerAdapter } from "./client.js";
7
+ import { defineParrelLedger } from "./define-ledger.js";
8
+ /** @deprecated Use {@link defineParrelLedger}. Removed in the next major version. */
9
+ export const defineParrelCms = defineParrelLedger;
10
+ /** @deprecated Use {@link createParrelLedgerServerAdapter}. Removed in the next major version. */
11
+ export const createParrelCmsServerAdapter = createParrelLedgerServerAdapter;
12
+ /** @deprecated Use {@link LedgerCache}. Removed in the next major version. */
13
+ export const CmsCache = LedgerCache;
14
+ //# sourceMappingURL=deprecated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deprecated.js","sourceRoot":"","sources":["../../src/core/deprecated.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,qFAAqF;AACrF,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAElD,kGAAkG;AAClG,MAAM,CAAC,MAAM,4BAA4B,GAAG,+BAA+B,CAAC;AAE5E,8EAA8E;AAC9E,MAAM,CAAC,MAAM,QAAQ,GAAG,WAAW,CAAC"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * How a package picks its backend: `"auto"` (the default) uses the mock adapter outside production and the
3
+ * Parrel service in production, `"live"` always uses the Parrel service, also in development.
4
+ */
5
+ export type ParrelMode = "auto" | "live";
6
+ /** The production origin of the Parrel API. Every package builds its base URL from it, unless you override it. */
7
+ export declare const PARREL_DEFAULT_API_ORIGIN = "https://api.parrel.dev";
8
+ /** Code of the error that a refused API origin throws. See `docs/errors/SD00100008.md`. */
9
+ export declare const PARREL_API_ORIGIN_ERROR_CODE = "SD00100008";
10
+ /**
11
+ * Returns the origin of the Parrel API that this app talks to, without a trailing slash.
12
+ *
13
+ * The first one that is set wins: the `explicit` value (the `apiOrigin` option of the configuration), then the
14
+ * `PARREL_API_ORIGIN` environment variable, then `https://api.parrel.dev`. Browser-only apps cannot read
15
+ * environment variables, so they pass their framework's public variable as `apiOrigin`.
16
+ *
17
+ * Only `https://` origins are allowed, except `http://` on `localhost`, `127.0.0.1` or `[::1]`, so a session
18
+ * cookie or a token never travels over plain HTTP to a remote host. The origin must not have a path or a query.
19
+ * Outside production, the origin is logged once with `console.info` when it differs from the default.
20
+ *
21
+ * @param explicit The `apiOrigin` option of the configuration, if there is one
22
+ * @returns The origin, for example `http://localhost:18700`
23
+ * @throws {ParrelError} `SD00100008` when the origin is not allowed
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * resolveParrelApiOrigin(); // https://api.parrel.dev
28
+ * resolveParrelApiOrigin("http://localhost:18700/"); // http://localhost:18700
29
+ * resolveParrelApiOrigin("http://example.com"); // throws ParrelError SD00100008
30
+ * ```
31
+ */
32
+ export declare function resolveParrelApiOrigin(explicit?: string): string;
33
+ /**
34
+ * Checks an `apiOrigin` option without logging, so a configuration mistake fails when the app starts.
35
+ *
36
+ * @throws {ParrelError} `SD00100008` when the origin is not allowed
37
+ */
38
+ export declare function assertParrelApiOrigin(apiOrigin: string | undefined): void;
39
+ /**
40
+ * Whether development mode must use the real Parrel service instead of the mock adapter: the `mode` option is
41
+ * `"live"` or the `PARREL_FORCE_LIVE` environment variable is `1`.
42
+ *
43
+ * @param mode The `mode` option of the configuration
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * isParrelForceLive("live"); // true
48
+ * isParrelForceLive(); // true when PARREL_FORCE_LIVE=1
49
+ * ```
50
+ */
51
+ export declare function isParrelForceLive(mode?: ParrelMode): boolean;
52
+ /** Code of the error that a site origin in the wrong form throws. See `docs/errors/SD00100018.md`. */
53
+ export declare const PARREL_SITE_ORIGIN_INVALID_CODE = "SD00100018";
54
+ /** Code of the error that a read from a server without a site origin throws. See `docs/errors/SD00100019.md`. */
55
+ export declare const PARREL_SITE_ORIGIN_REQUIRED_CODE = "SD00100019";
56
+ /**
57
+ * Returns the origin of your own site, which a read from a server sends as its `Origin` header, or `undefined` when
58
+ * none is set.
59
+ *
60
+ * The `explicit` value (the `siteOrigin` option of the configuration) wins over the `PARREL_SITE_ORIGIN` environment
61
+ * variable. There is no default. The value is trimmed, a bare domain gets `https://`, and the result is lower case
62
+ * without a trailing slash. `localhost` is allowed with `http://` or `https://` on any port; any other host must be
63
+ * `https://` without a port, a path, a query or a fragment. Give the origin that is on the list of your Ledger
64
+ * service in the Parrel portal: the package sends exactly what is configured.
65
+ *
66
+ * @param explicit The `siteOrigin` option of the configuration, if there is one
67
+ * @returns The origin, for example `https://shop.be`, or `undefined`
68
+ * @throws {ParrelError} `SD00100018` when the origin is not in a form Ledger accepts
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * resolveParrelSiteOrigin("Shop.be/"); // https://shop.be
73
+ * resolveParrelSiteOrigin("http://localhost:3000"); // http://localhost:3000
74
+ * resolveParrelSiteOrigin("https://shop.be/contact"); // throws ParrelError SD00100018
75
+ * ```
76
+ */
77
+ export declare function resolveParrelSiteOrigin(explicit?: string): string | undefined;
78
+ /**
79
+ * Like {@link resolveParrelSiteOrigin}, but a missing origin throws: a read from a server in production must send one.
80
+ *
81
+ * @throws {ParrelError} `SD00100019` when neither `siteOrigin` nor `PARREL_SITE_ORIGIN` is set
82
+ * @throws {ParrelError} `SD00100018` when the origin is not in a form Ledger accepts
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * const origin = requireParrelSiteOrigin(config.siteOrigin); // "https://shop.be"
87
+ * ```
88
+ */
89
+ export declare function requireParrelSiteOrigin(explicit?: string): string;
90
+ /**
91
+ * Checks a `siteOrigin` option, so a configuration mistake fails when the app starts.
92
+ *
93
+ * @throws {ParrelError} `SD00100018` when the origin is not in a form Ledger accepts
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * assertParrelSiteOrigin("https://shop.be/contact"); // throws ParrelError SD00100018
98
+ * ```
99
+ */
100
+ export declare function assertParrelSiteOrigin(siteOrigin: string | undefined): void;
101
+ /** Forgets which origins were announced (for tests). */
102
+ export declare function resetParrelApiOriginLog(): void;
103
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/core/env.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzC,kHAAkH;AAClH,eAAO,MAAM,yBAAyB,2BAA2B,CAAC;AAElE,2FAA2F;AAC3F,eAAO,MAAM,4BAA4B,eAAe,CAAC;AA6CzD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAUhE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAIzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAM5D;AAED,sGAAsG;AACtG,eAAO,MAAM,+BAA+B,eAAe,CAAC;AAE5D,iHAAiH;AACjH,eAAO,MAAM,gCAAgC,eAAe,CAAC;AAyC7D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG7E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAMjE;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAI3E;AAED,wDAAwD;AACxD,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C"}
@@ -0,0 +1,208 @@
1
+ import { isParrelProduction } from "@parrel/sentinel";
2
+ import { ParrelError } from "./parrel-error.js";
3
+ /** The production origin of the Parrel API. Every package builds its base URL from it, unless you override it. */
4
+ export const PARREL_DEFAULT_API_ORIGIN = "https://api.parrel.dev";
5
+ /** Code of the error that a refused API origin throws. See `docs/errors/SD00100008.md`. */
6
+ export const PARREL_API_ORIGIN_ERROR_CODE = "SD00100008";
7
+ const API_ORIGIN_ERROR_MESSAGE = "Ledger cannot use this API origin. Set apiOrigin or PARREL_API_ORIGIN to an https:// origin without a path or query, such as https://api.parrel.dev, or to an http:// origin on localhost, 127.0.0.1 or [::1] for local development.";
8
+ const LOCAL_HOSTS = new Set(["localhost", "127.0.0.1", "[::1]"]);
9
+ /** Origins that were already announced, so the log line appears once for each origin. */
10
+ const announcedOrigins = new Set();
11
+ function readApiOriginEnv() {
12
+ try {
13
+ return typeof process === "undefined" ? undefined : process.env.PARREL_API_ORIGIN;
14
+ }
15
+ catch {
16
+ return undefined;
17
+ }
18
+ }
19
+ function readForceLiveEnv() {
20
+ try {
21
+ return typeof process === "undefined" ? undefined : process.env.PARREL_FORCE_LIVE;
22
+ }
23
+ catch {
24
+ return undefined;
25
+ }
26
+ }
27
+ /** Checks one origin and returns it in its normal form. Throws the coded error when it is not allowed. */
28
+ function validateApiOrigin(value) {
29
+ // One trailing slash is fine; a path, a query, a fragment or user information is not.
30
+ const text = value.trim().replace(/\/$/, "");
31
+ const match = /^(https?):\/\/[^/?#@\s]+$/i.exec(text);
32
+ let url = null;
33
+ if (match) {
34
+ try {
35
+ url = new URL(text);
36
+ }
37
+ catch {
38
+ url = null;
39
+ }
40
+ }
41
+ if (!url || (url.protocol === "http:" && !LOCAL_HOSTS.has(url.hostname))) {
42
+ throw new ParrelError(PARREL_API_ORIGIN_ERROR_CODE, API_ORIGIN_ERROR_MESSAGE);
43
+ }
44
+ return url.origin;
45
+ }
46
+ /**
47
+ * Returns the origin of the Parrel API that this app talks to, without a trailing slash.
48
+ *
49
+ * The first one that is set wins: the `explicit` value (the `apiOrigin` option of the configuration), then the
50
+ * `PARREL_API_ORIGIN` environment variable, then `https://api.parrel.dev`. Browser-only apps cannot read
51
+ * environment variables, so they pass their framework's public variable as `apiOrigin`.
52
+ *
53
+ * Only `https://` origins are allowed, except `http://` on `localhost`, `127.0.0.1` or `[::1]`, so a session
54
+ * cookie or a token never travels over plain HTTP to a remote host. The origin must not have a path or a query.
55
+ * Outside production, the origin is logged once with `console.info` when it differs from the default.
56
+ *
57
+ * @param explicit The `apiOrigin` option of the configuration, if there is one
58
+ * @returns The origin, for example `http://localhost:18700`
59
+ * @throws {ParrelError} `SD00100008` when the origin is not allowed
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * resolveParrelApiOrigin(); // https://api.parrel.dev
64
+ * resolveParrelApiOrigin("http://localhost:18700/"); // http://localhost:18700
65
+ * resolveParrelApiOrigin("http://example.com"); // throws ParrelError SD00100008
66
+ * ```
67
+ */
68
+ export function resolveParrelApiOrigin(explicit) {
69
+ const fromConfig = explicit?.trim();
70
+ const fromEnv = readApiOriginEnv()?.trim();
71
+ const origin = validateApiOrigin(fromConfig || fromEnv || PARREL_DEFAULT_API_ORIGIN);
72
+ if (origin !== PARREL_DEFAULT_API_ORIGIN && !isParrelProduction() && !announcedOrigins.has(origin)) {
73
+ announcedOrigins.add(origin);
74
+ console.info(`[parrel] Using the API origin ${origin} (from apiOrigin or PARREL_API_ORIGIN).`);
75
+ }
76
+ return origin;
77
+ }
78
+ /**
79
+ * Checks an `apiOrigin` option without logging, so a configuration mistake fails when the app starts.
80
+ *
81
+ * @throws {ParrelError} `SD00100008` when the origin is not allowed
82
+ */
83
+ export function assertParrelApiOrigin(apiOrigin) {
84
+ if (apiOrigin !== undefined && apiOrigin.trim() !== "") {
85
+ validateApiOrigin(apiOrigin);
86
+ }
87
+ }
88
+ /**
89
+ * Whether development mode must use the real Parrel service instead of the mock adapter: the `mode` option is
90
+ * `"live"` or the `PARREL_FORCE_LIVE` environment variable is `1`.
91
+ *
92
+ * @param mode The `mode` option of the configuration
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * isParrelForceLive("live"); // true
97
+ * isParrelForceLive(); // true when PARREL_FORCE_LIVE=1
98
+ * ```
99
+ */
100
+ export function isParrelForceLive(mode) {
101
+ if (mode === "live") {
102
+ return true;
103
+ }
104
+ const flag = readForceLiveEnv()?.trim().toLowerCase();
105
+ return flag === "1" || flag === "true";
106
+ }
107
+ /** Code of the error that a site origin in the wrong form throws. See `docs/errors/SD00100018.md`. */
108
+ export const PARREL_SITE_ORIGIN_INVALID_CODE = "SD00100018";
109
+ /** Code of the error that a read from a server without a site origin throws. See `docs/errors/SD00100019.md`. */
110
+ export const PARREL_SITE_ORIGIN_REQUIRED_CODE = "SD00100019";
111
+ const SITE_ORIGIN_INVALID_MESSAGE = "Ledger cannot use this site origin. Set siteOrigin or PARREL_SITE_ORIGIN to the origin of your site, such as https://shop.be, or to localhost for local development.";
112
+ const SITE_ORIGIN_REQUIRED_MESSAGE = "Ledger needs the origin of your site for calls from a server. Set siteOrigin in defineParrelLedger or the environment variable PARREL_SITE_ORIGIN to an origin you added to your Ledger service in the Parrel portal.";
113
+ function readSiteOriginEnv() {
114
+ try {
115
+ return typeof process === "undefined" ? undefined : process.env.PARREL_SITE_ORIGIN;
116
+ }
117
+ catch {
118
+ return undefined;
119
+ }
120
+ }
121
+ /**
122
+ * Checks one site origin and returns it in its normal form: lower case, no trailing slash, `https://` added to a bare
123
+ * domain. `localhost` may use either scheme and any port; any other host is `https://` without a port.
124
+ */
125
+ function validateSiteOrigin(value) {
126
+ let text = value.trim().replace(/\/$/, "");
127
+ if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(text)) {
128
+ text = `https://${text}`;
129
+ }
130
+ const match = /^(https?):\/\/[^/?#@\s]+$/i.exec(text);
131
+ let url = null;
132
+ if (match) {
133
+ try {
134
+ url = new URL(text);
135
+ }
136
+ catch {
137
+ url = null;
138
+ }
139
+ }
140
+ const allowed = url !== null && (url.hostname === "localhost" || (url.protocol === "https:" && url.port === ""));
141
+ if (!url || !allowed) {
142
+ throw new ParrelError(PARREL_SITE_ORIGIN_INVALID_CODE, SITE_ORIGIN_INVALID_MESSAGE);
143
+ }
144
+ return url.origin;
145
+ }
146
+ /**
147
+ * Returns the origin of your own site, which a read from a server sends as its `Origin` header, or `undefined` when
148
+ * none is set.
149
+ *
150
+ * The `explicit` value (the `siteOrigin` option of the configuration) wins over the `PARREL_SITE_ORIGIN` environment
151
+ * variable. There is no default. The value is trimmed, a bare domain gets `https://`, and the result is lower case
152
+ * without a trailing slash. `localhost` is allowed with `http://` or `https://` on any port; any other host must be
153
+ * `https://` without a port, a path, a query or a fragment. Give the origin that is on the list of your Ledger
154
+ * service in the Parrel portal: the package sends exactly what is configured.
155
+ *
156
+ * @param explicit The `siteOrigin` option of the configuration, if there is one
157
+ * @returns The origin, for example `https://shop.be`, or `undefined`
158
+ * @throws {ParrelError} `SD00100018` when the origin is not in a form Ledger accepts
159
+ *
160
+ * @example
161
+ * ```ts
162
+ * resolveParrelSiteOrigin("Shop.be/"); // https://shop.be
163
+ * resolveParrelSiteOrigin("http://localhost:3000"); // http://localhost:3000
164
+ * resolveParrelSiteOrigin("https://shop.be/contact"); // throws ParrelError SD00100018
165
+ * ```
166
+ */
167
+ export function resolveParrelSiteOrigin(explicit) {
168
+ const value = explicit?.trim() || readSiteOriginEnv()?.trim();
169
+ return value ? validateSiteOrigin(value) : undefined;
170
+ }
171
+ /**
172
+ * Like {@link resolveParrelSiteOrigin}, but a missing origin throws: a read from a server in production must send one.
173
+ *
174
+ * @throws {ParrelError} `SD00100019` when neither `siteOrigin` nor `PARREL_SITE_ORIGIN` is set
175
+ * @throws {ParrelError} `SD00100018` when the origin is not in a form Ledger accepts
176
+ *
177
+ * @example
178
+ * ```ts
179
+ * const origin = requireParrelSiteOrigin(config.siteOrigin); // "https://shop.be"
180
+ * ```
181
+ */
182
+ export function requireParrelSiteOrigin(explicit) {
183
+ const origin = resolveParrelSiteOrigin(explicit);
184
+ if (!origin) {
185
+ throw new ParrelError(PARREL_SITE_ORIGIN_REQUIRED_CODE, SITE_ORIGIN_REQUIRED_MESSAGE);
186
+ }
187
+ return origin;
188
+ }
189
+ /**
190
+ * Checks a `siteOrigin` option, so a configuration mistake fails when the app starts.
191
+ *
192
+ * @throws {ParrelError} `SD00100018` when the origin is not in a form Ledger accepts
193
+ *
194
+ * @example
195
+ * ```ts
196
+ * assertParrelSiteOrigin("https://shop.be/contact"); // throws ParrelError SD00100018
197
+ * ```
198
+ */
199
+ export function assertParrelSiteOrigin(siteOrigin) {
200
+ if (siteOrigin !== undefined && siteOrigin.trim() !== "") {
201
+ validateSiteOrigin(siteOrigin);
202
+ }
203
+ }
204
+ /** Forgets which origins were announced (for tests). */
205
+ export function resetParrelApiOriginLog() {
206
+ announcedOrigins.clear();
207
+ }
208
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/core/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAQhD,kHAAkH;AAClH,MAAM,CAAC,MAAM,yBAAyB,GAAG,wBAAwB,CAAC;AAElE,2FAA2F;AAC3F,MAAM,CAAC,MAAM,4BAA4B,GAAG,YAAY,CAAC;AAEzD,MAAM,wBAAwB,GAC7B,sOAAsO,CAAC;AAExO,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;AAEjE,yFAAyF;AACzF,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;AAE3C,SAAS,gBAAgB;IACxB,IAAI,CAAC;QACJ,OAAO,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,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AC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAAiB;IACxD,MAAM,MAAM,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IACjD,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,MAAM,IAAI,WAAW,CAAC,gCAAgC,EAAE,4BAA4B,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAA8B;IACpE,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC1D,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;AACF,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,uBAAuB;IACtC,gBAAgB,CAAC,KAAK,EAAE,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Every error code that @parrel/ledger knows: 114 LE and 47 SD codes. The LE codes belong to the Ledger
3
+ * endpoints that the package calls, the SD codes are raised by the package itself. The page of a code is at
4
+ * `https://docs.parrel.dev/errors/<code>`.
5
+ */
6
+ export type LedgerKnownErrorCode = "LE00100002" | "LE00100003" | "LE00100004" | "LE00100005" | "LE00100006" | "LE00100007" | "LE01000001" | "LE01000002" | "LE01000003" | "LE01000004" | "LE01000005" | "LE01000006" | "LE01000007" | "LE01000008" | "LE01000009" | "LE01000010" | "LE01000011" | "LE01000012" | "LE01000013" | "LE01000014" | "LE01000015" | "LE01000016" | "LE01000017" | "LE01000018" | "LE01000019" | "LE01000020" | "LE01000021" | "LE01000022" | "LE01000023" | "LE01000024" | "LE01000025" | "LE01000026" | "LE01000027" | "LE01000028" | "LE01000029" | "LE01000030" | "LE01000031" | "LE01000032" | "LE01000033" | "LE01000041" | "LE01000042" | "LE01000043" | "LE01000044" | "LE02000001" | "LE02000002" | "LE02000003" | "LE02000004" | "LE02000005" | "LE02000006" | "LE02000007" | "LE02000008" | "LE02000009" | "LE02000010" | "LE02000011" | "LE02000012" | "LE02000013" | "LE02000014" | "LE02000015" | "LE02000016" | "LE02000017" | "LE02000018" | "LE02000019" | "LE02000020" | "LE02000021" | "LE02000022" | "LE02000023" | "LE02000024" | "LE02500001" | "LE02500002" | "LE02500003" | "LE02500004" | "LE02500005" | "LE02500006" | "LE02500007" | "LE02500008" | "LE02500009" | "LE02500010" | "LE02500011" | "LE02500012" | "LE02500013" | "LE02500014" | "LE02500015" | "LE02500016" | "LE02500017" | "LE02500018" | "LE02500019" | "LE02500020" | "LE02500021" | "LE02500022" | "LE03000001" | "LE04000015" | "LE04000016" | "LE04000017" | "LE04000018" | "LE04000019" | "LE04000021" | "LE04000022" | "LE04000023" | "LE04000024" | "LE04000026" | "LE04000027" | "LE04000028" | "LE04000029" | "LE09000023" | "LE09900001" | "LE09900002" | "LE09900003" | "LE09900004" | "LE09900005" | "LE09900006" | "LE09900007" | "LE09900008" | "LE09900011" | "LE09900012" | "SD00100001" | "SD00100002" | "SD00100003" | "SD00100008" | "SD00100018" | "SD00100019" | "SD01000001" | "SD01000002" | "SD01000003" | "SD01000004" | "SD01000005" | "SD01000012" | "SD01000014" | "SD02000001" | "SD02000002" | "SD02000003" | "SD02000004" | "SD02000005" | "SD02000006" | "SD02000008" | "SD05000002" | "SD05000003" | "SD05000007" | "SD05000008" | "SD05000010" | "SD05000011" | "SD05000012" | "SD05000013" | "SD05000015" | "SD05000023" | "SD05000024" | "SD05000025" | "SD05000026" | "SD05000027" | "SD05000028" | "SD05000029" | "SD06000001" | "SD06000002" | "SD06000003" | "SD06000004" | "SD06000005" | "SD06000006" | "SD06000007" | "SD06000009" | "SD06000010" | "SD06000011" | "SD06000012";
7
+ /**
8
+ * An error code of @parrel/ledger. A backend can return a code that this version does not know yet, so the
9
+ * type also accepts any other string. The known codes still show up in the editor.
10
+ */
11
+ export type LedgerErrorCode = LedgerKnownErrorCode | (string & Record<never, never>);
12
+ //# sourceMappingURL=error-codes.generated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-codes.generated.d.ts","sourceRoot":"","sources":["../../src/core/error-codes.generated.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAC7B,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,CAAC;AAEhB;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,oBAAoB,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ // Generated by scripts/errors/cli.mjs from the Parrel error pages. Do not edit by hand. Run `npm run errors:update`.
2
+ export {};
3
+ //# sourceMappingURL=error-codes.generated.js.map