@lango-project/lango-boss 0.0.0-stage → 0.1.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 (117) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +2 -0
  3. package/README.md +111 -2
  4. package/dist/.lango/bignumber.mjs +3119 -0
  5. package/dist/.lango/localization.mjs +108 -0
  6. package/dist/.lango/runtime.mjs +725 -0
  7. package/dist/.lango/vendor/i18next.LICENSE +21 -0
  8. package/dist/.lango/vendor/i18next.mjs +2434 -0
  9. package/dist/.lango/xmldom/conventions.js +429 -0
  10. package/dist/.lango/xmldom/dom-parser.js +591 -0
  11. package/dist/.lango/xmldom/dom.js +3759 -0
  12. package/dist/.lango/xmldom/entities.js +2171 -0
  13. package/dist/.lango/xmldom/errors.js +205 -0
  14. package/dist/.lango/xmldom/grammar.js +559 -0
  15. package/dist/.lango/xmldom/index.js +41 -0
  16. package/dist/.lango/xmldom/package.json +1 -0
  17. package/dist/.lango/xmldom/sax.js +983 -0
  18. package/dist/.lango/xmldom.LICENSE.md +8 -0
  19. package/dist/boss.mjs +136 -0
  20. package/dist/boss.mjs.map +1 -0
  21. package/dist/claim_watch.mjs +99 -0
  22. package/dist/claim_watch.mjs.map +1 -0
  23. package/dist/cli.mjs +143 -0
  24. package/dist/cli.mjs.map +1 -0
  25. package/dist/configuration.mjs +58 -0
  26. package/dist/configuration.mjs.map +1 -0
  27. package/dist/dispatcher.mjs +108 -0
  28. package/dist/dispatcher.mjs.map +1 -0
  29. package/dist/driver.mjs +98 -0
  30. package/dist/driver.mjs.map +1 -0
  31. package/dist/envelope.mjs +92 -0
  32. package/dist/envelope.mjs.map +1 -0
  33. package/dist/library.mjs +139 -0
  34. package/dist/library.mjs.map +1 -0
  35. package/dist/management.mjs +360 -0
  36. package/dist/management.mjs.map +1 -0
  37. package/dist/management_transaction.mjs +26 -0
  38. package/dist/management_transaction.mjs.map +1 -0
  39. package/dist/namespace.mjs +27 -0
  40. package/dist/namespace.mjs.map +1 -0
  41. package/dist/queue.mjs +161 -0
  42. package/dist/queue.mjs.map +1 -0
  43. package/dist/reads.mjs +359 -0
  44. package/dist/reads.mjs.map +1 -0
  45. package/dist/retention.mjs +133 -0
  46. package/dist/retention.mjs.map +1 -0
  47. package/dist/schedule_sync.mjs +222 -0
  48. package/dist/schedule_sync.mjs.map +1 -0
  49. package/dist/schedule_transaction.mjs +24 -0
  50. package/dist/schedule_transaction.mjs.map +1 -0
  51. package/dist/schedules.mjs +201 -0
  52. package/dist/schedules.mjs.map +1 -0
  53. package/dist/transaction.mjs +16 -0
  54. package/dist/transaction.mjs.map +1 -0
  55. package/dist/validation.mjs +90 -0
  56. package/dist/validation.mjs.map +1 -0
  57. package/dist/worker.mjs +316 -0
  58. package/dist/worker.mjs.map +1 -0
  59. package/docs/guide.md +88 -0
  60. package/docs/management.md +93 -0
  61. package/docs/producer.md +115 -0
  62. package/docs/reads.md +107 -0
  63. package/docs/reference.md +77 -0
  64. package/docs/release.md +103 -0
  65. package/docs/retention.md +47 -0
  66. package/docs/scheduling.md +79 -0
  67. package/docs/worker.md +90 -0
  68. package/examples/reports/README.md +118 -0
  69. package/examples/reports/app.lango +133 -0
  70. package/examples/reports/deploy.xml +6 -0
  71. package/examples/reports/dist/.lango/bignumber.mjs +3119 -0
  72. package/examples/reports/dist/.lango/localization.mjs +108 -0
  73. package/examples/reports/dist/.lango/runtime.mjs +725 -0
  74. package/examples/reports/dist/.lango/vendor/i18next.LICENSE +21 -0
  75. package/examples/reports/dist/.lango/vendor/i18next.mjs +2434 -0
  76. package/examples/reports/dist/.lango/xmldom/conventions.js +429 -0
  77. package/examples/reports/dist/.lango/xmldom/dom-parser.js +591 -0
  78. package/examples/reports/dist/.lango/xmldom/dom.js +3759 -0
  79. package/examples/reports/dist/.lango/xmldom/entities.js +2171 -0
  80. package/examples/reports/dist/.lango/xmldom/errors.js +205 -0
  81. package/examples/reports/dist/.lango/xmldom/grammar.js +559 -0
  82. package/examples/reports/dist/.lango/xmldom/index.js +41 -0
  83. package/examples/reports/dist/.lango/xmldom/package.json +1 -0
  84. package/examples/reports/dist/.lango/xmldom/sax.js +983 -0
  85. package/examples/reports/dist/.lango/xmldom.LICENSE.md +8 -0
  86. package/examples/reports/dist/app.mjs +137 -0
  87. package/examples/reports/dist/app.mjs.map +1 -0
  88. package/examples/reports/dist/handlers.mjs +202 -0
  89. package/examples/reports/dist/handlers.mjs.map +1 -0
  90. package/examples/reports/dist/setup.mjs +14 -0
  91. package/examples/reports/dist/setup.mjs.map +1 -0
  92. package/examples/reports/handlers.lango +153 -0
  93. package/examples/reports/jobs.xml +5 -0
  94. package/examples/reports/package.json +23 -0
  95. package/examples/reports/routes.xml +4 -0
  96. package/examples/reports/setup.lango +17 -0
  97. package/package.json +60 -4
  98. package/src/boss.lango +92 -0
  99. package/src/claim_watch.lango +58 -0
  100. package/src/cli.lango +103 -0
  101. package/src/configuration.lango +43 -0
  102. package/src/dispatcher.lango +75 -0
  103. package/src/driver.lango +72 -0
  104. package/src/envelope.lango +56 -0
  105. package/src/library.lango +66 -0
  106. package/src/management.lango +302 -0
  107. package/src/management_transaction.lango +28 -0
  108. package/src/namespace.lango +15 -0
  109. package/src/queue.lango +115 -0
  110. package/src/reads.lango +277 -0
  111. package/src/retention.lango +107 -0
  112. package/src/schedule_sync.lango +190 -0
  113. package/src/schedule_transaction.lango +22 -0
  114. package/src/schedules.lango +165 -0
  115. package/src/transaction.lango +23 -0
  116. package/src/validation.lango +45 -0
  117. package/src/worker.lango +230 -0
@@ -0,0 +1,222 @@
1
+ import { schemaName, scheduleKey } from "./namespace.mjs";
2
+ import * as server from "@lango-project/lango-server";
3
+ import * as crypto from "node:crypto";
4
+ import {
5
+ hostGlobal as __hostGlobal,
6
+ contextGet as __contextGet,
7
+ contextSet as __contextSet,
8
+ contextRestore as __contextRestore,
9
+ bindContexts as __bindContexts,
10
+ fromJson as __fromJson,
11
+ toJson as __toJson,
12
+ isNumber as __isNumber,
13
+ isString as __isString,
14
+ isBool as __isBool,
15
+ isObject as __isObject,
16
+ isArray as __isArray,
17
+ requireBoolean as __requireBoolean,
18
+ normalize as __normalize,
19
+ boundary as __boundary,
20
+ startTrans as __startTrans,
21
+ commitTrans as __commitTrans,
22
+ rollbackTrans as __rollbackTrans,
23
+ transState as __transState,
24
+ query as __query,
25
+ requireArity as __requireArity,
26
+ } from "./.lango/runtime.mjs";
27
+
28
+ export function synchronizeSchedules(config) {
29
+ __requireArity(arguments.length, [0], "synchronizeSchedules");
30
+ config = __boundary(config);
31
+ let action = __bindContexts(() => {
32
+ return synchronize(config);
33
+ return null;
34
+ });
35
+ return __normalize(server.withDatabase(__normalize(config.root), action));
36
+ return null;
37
+ }
38
+
39
+ function fingerprint(items) {
40
+ __requireArity(arguments.length, [0], "fingerprint");
41
+ items = __boundary(items);
42
+ let definitions = __normalize(__hostGlobal(["Object"]).create(null));
43
+ for (const item of items) {
44
+ definitions[__normalize(item.name)] = item;
45
+ }
46
+ let hash = __normalize(crypto.createHash("sha256"));
47
+ __normalize(hash.update(__toJson(canonical(definitions))));
48
+ return __normalize(hash.digest("hex"));
49
+ return null;
50
+ }
51
+
52
+ function canonical(value) {
53
+ __requireArity(arguments.length, [0], "canonical");
54
+ value = __boundary(value);
55
+ let array;
56
+ let result;
57
+ let keys;
58
+ if (__requireBoolean(__isArray(value))) {
59
+ array = [];
60
+ for (const item of value) {
61
+ array.push(canonical(item));
62
+ }
63
+ return array;
64
+ }
65
+ if (__requireBoolean(__requireBoolean(__isObject(value)) && __requireBoolean(value !== null))) {
66
+ result = __normalize(__hostGlobal(["Object"]).create(null));
67
+ keys = __normalize(__hostGlobal(["Object"]).keys(value));
68
+ __normalize(keys.sort());
69
+ for (const key of keys) {
70
+ result[key] = canonical(__normalize(value[key]));
71
+ }
72
+ return result;
73
+ }
74
+ return value;
75
+ return null;
76
+ }
77
+
78
+ function synchronize(config) {
79
+ __requireArity(arguments.length, [0], "synchronize");
80
+ config = __boundary(config);
81
+ let lock;
82
+ let stamp;
83
+ let current;
84
+ let store;
85
+ let schema = schemaName(__normalize(config.application));
86
+ let search = __query("select set_config('search_path', :schema, false)", ["schema"]);
87
+ search.schema = schema;
88
+ __normalize(search.execute());
89
+ __startTrans();
90
+ try {
91
+ lock = __query("select pg_advisory_xact_lock(hashtextextended(:name, 0))", ["name"]);
92
+ lock.name = `lango-boss:schedules:${__normalize(config.application)}`;
93
+ __normalize(lock.execute());
94
+ initializeSchedules(schema);
95
+ stamp = fingerprint(__normalize(config.schedules));
96
+ current = __query("select application, revision, fingerprint from lango_schedule_state where id = 1 for update", []);
97
+ __normalize(current.execute());
98
+ if (__requireBoolean(__normalize(current.next()))) {
99
+ if (__requireBoolean(__normalize(current.application) !== __normalize(config.application))) {
100
+ throw "Schedule schema belongs to another application";
101
+ }
102
+ if (__requireBoolean(__normalize(config.scheduleRevision) < __normalize(current.revision))) {
103
+ throw "Schedule revision is older than the deployed revision";
104
+ }
105
+ if (__requireBoolean(__requireBoolean(__normalize(config.scheduleRevision) === __normalize(current.revision)) && __requireBoolean(stamp !== __normalize(current.fingerprint)))) {
106
+ throw "Schedule content changed without increasing revision";
107
+ }
108
+ }
109
+ applyDefinitions(config, schema);
110
+ store = __query("insert into lango_schedule_state (id, application, revision, fingerprint)\nvalues (1, :application, :revision, :fingerprint)\non conflict (id) do update set revision = excluded.revision,\n fingerprint = excluded.fingerprint, updated_at = now()", ["application","revision","fingerprint"]);
111
+ store.application = __normalize(config.application);
112
+ store.revision = __normalize(config.scheduleRevision);
113
+ store.fingerprint = stamp;
114
+ __normalize(store.execute());
115
+ __commitTrans();
116
+ } catch (error) {
117
+ __rollbackTrans();
118
+ throw error;
119
+ }
120
+ return null;
121
+ return null;
122
+ }
123
+
124
+ export function initializeSchedules(schema) {
125
+ __requireArity(arguments.length, [0], "initializeSchedules");
126
+ schema = __boundary(schema);
127
+ let state = __query("create table if not exists " + String(schema) + ".lango_schedule_state (\n id integer primary key check (id = 1), application text not null,\n revision integer not null, fingerprint text not null,\n updated_at timestamptz not null default now()\n)", []);
128
+ __normalize(state.execute());
129
+ let entries = __query("create table if not exists " + String(schema) + ".lango_schedule_definitions (\n name text primary key, queue text not null, key text not null,\n definition jsonb not null, paused boolean not null default false,\n present boolean not null default true,\n updated_at timestamptz not null default now(), unique (queue, key)\n)", []);
130
+ __normalize(entries.execute());
131
+ return null;
132
+ return null;
133
+ }
134
+
135
+ export function operation(schema, action, queue, key, item = null) {
136
+ const __contextScope = [];
137
+ try {
138
+ __requireArity(arguments.length, [0, 1, 2, 3], "operation");
139
+ schema = __boundary(schema);
140
+ action = __boundary(action);
141
+ queue = __boundary(queue);
142
+ key = __boundary(key);
143
+ item = __boundary(item);
144
+ let input = { schema: schema, action: action, queue: queue, key: key };
145
+ if (__requireBoolean(item !== null)) {
146
+ input.cron = __normalize(item.cron);
147
+ input.payload = { version: 1, application: __normalize(item.application), path: __normalize(item.path), input: __normalize(item.data), source: { kind: "system", identity: __normalize(item.identity) }, failedRetentionSeconds: item.retry.failedRetentionSeconds };
148
+ input.options = { key: key, tz: __normalize(item.timeZone), missed: __normalize(item.missed), precision: __normalize(item.precision), retryLimit: item.retry.retryLimit, retryDelay: item.retry.retryDelay, retryBackoff: item.retry.retryBackoff, retryDelayMax: item.retry.retryDelayMax, expireInSeconds: item.retry.expireInSeconds, heartbeatSeconds: 30, deleteAfterSeconds: 0 };
149
+ }
150
+ return __normalize(__contextGet("db").invoke({ module: "@lango-project/lango-boss/schedule-transaction", handler: "apply" }, input));
151
+ return null;
152
+ } finally {
153
+ __contextRestore(__contextScope);
154
+ }
155
+ }
156
+
157
+ function applyDefinitions(config, schema) {
158
+ __requireArity(arguments.length, [0, 1], "applyDefinitions");
159
+ config = __boundary(config);
160
+ schema = __boundary(schema);
161
+ let desired = __normalize(__hostGlobal(["Object"]).create(null));
162
+ for (const item of __normalize(config.schedules)) {
163
+ desired[__normalize(item.name)] = true;
164
+ }
165
+ let existing = __query("select name, queue, key from lango_schedule_definitions where present = true", []);
166
+ __normalize(existing.execute());
167
+ __loop1: while (__requireBoolean(__normalize(existing.next()))) {
168
+ if (__requireBoolean(!__requireBoolean(__normalize(__hostGlobal(["Object"]).hasOwn(desired, __normalize(existing.name)))))) {
169
+ operation(schema, "remove", __normalize(existing.queue), __normalize(existing.key));
170
+ let missing = __query("update lango_schedule_definitions set present = false, updated_at = now() where name = :name", ["name"]);
171
+ missing.name = __normalize(existing.name);
172
+ __normalize(missing.execute());
173
+ }
174
+ }
175
+ for (const item of __normalize(config.schedules)) {
176
+ applyDefinition(__normalize(config.application), schema, item);
177
+ }
178
+ return null;
179
+ return null;
180
+ }
181
+
182
+ function applyDefinition(application, schema, supplied) {
183
+ __requireArity(arguments.length, [0, 1, 2], "applyDefinition");
184
+ application = __boundary(application);
185
+ schema = __boundary(schema);
186
+ supplied = __boundary(supplied);
187
+ let collision;
188
+ let item = __normalize(__hostGlobal(["Object"]).assign({ }, supplied, { application: application }));
189
+ let key = scheduleKey(application, __normalize(item.name));
190
+ let old = __query("select queue, key, paused from lango_schedule_definitions where name = :name", ["name"]);
191
+ old.name = __normalize(item.name);
192
+ __normalize(old.execute());
193
+ let found = __normalize(old.next());
194
+ let paused = false;
195
+ if (__requireBoolean(found)) {
196
+ paused = __normalize(old.paused);
197
+ }
198
+ let moved = __requireBoolean(found) && __requireBoolean(__requireBoolean(__normalize(old.queue) !== __normalize(item.queue)) || __requireBoolean(__normalize(old.key) !== key));
199
+ if (__requireBoolean(__requireBoolean(!__requireBoolean(found)) || __requireBoolean(moved))) {
200
+ collision = operation(schema, "get", __normalize(item.queue), key);
201
+ if (__requireBoolean(collision !== null)) {
202
+ throw `Schedule key already exists outside the managed registry: ${__normalize(item.name)}`;
203
+ }
204
+ }
205
+ if (__requireBoolean(moved)) {
206
+ operation(schema, "remove", __normalize(old.queue), __normalize(old.key));
207
+ }
208
+ if (__requireBoolean(__requireBoolean(__normalize(item.enabled)) && __requireBoolean(!__requireBoolean(paused)))) {
209
+ operation(schema, "upsert", __normalize(item.queue), key, item);
210
+ } else {
211
+ operation(schema, "remove", __normalize(item.queue), key);
212
+ }
213
+ let store = __query("insert into lango_schedule_definitions (name, queue, key, definition)\nvalues (:name, :queue, :key, :definition::jsonb)\non conflict (name) do update set queue = excluded.queue, key = excluded.key,\n definition = excluded.definition, present = true, updated_at = now()", ["name","queue","key","definition"]);
214
+ store.name = __normalize(item.name);
215
+ store.queue = __normalize(item.queue);
216
+ store.key = key;
217
+ store.definition = __toJson(supplied);
218
+ __normalize(store.execute());
219
+ return null;
220
+ return null;
221
+ }
222
+ //# sourceMappingURL=schedule_sync.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule_sync.mjs","sources":["schedule_sync.lango"],"sourcesContent":["import \"./namespace\"\n schemaName(application)\n scheduleKey(application, name)\nimport js \"@lango-project/lango-server\" as server\nimport js \"node:crypto\" as crypto\nimport js global Object\n\nexport synchronizeSchedules(config)\nexport initializeSchedules(schema)\nexport operation(schema, action, queue, key, item = null)\n\nsynchronizeSchedules(config)\n action = ()\n capture config\n return synchronize(config)\n return server/withDatabase(config.root, action)\n\nfingerprint(items)\n definitions = Object/create(null)\n for items as item\n definitions[item.name] = item\n hash = crypto/createHash(\"sha256\")\n hash.update(to_json(canonical(definitions)))\n return hash.digest(\"hex\")\n\ncanonical(value)\n if is_array(value)\n array = []\n for value as item\n array.add(canonical(item))\n return array\n if is_object(value) and value != null\n result = Object/create(null)\n keys = Object/keys(value)\n keys.sort()\n for keys as key\n result[key] = canonical(value[key])\n return result\n return value\n\nsynchronize(config)\n schema = schemaName(config.application)\n search = SQL\n select set_config('search_path', :schema, false)\n search.schema = schema\n search.execute()\n start_trans()\n try\n lock = SQL\n select pg_advisory_xact_lock(hashtextextended(:name, 0))\n lock.name = \"lango-boss:schedules:${config.application}\"\n lock.execute()\n initializeSchedules(schema)\n stamp = fingerprint(config.schedules)\n current = SQL\n select application, revision, fingerprint from lango_schedule_state where id = 1 for update\n current.execute()\n if current.next()\n if current.application != config.application\n throw \"Schedule schema belongs to another application\"\n if config.scheduleRevision < current.revision\n throw \"Schedule revision is older than the deployed revision\"\n if config.scheduleRevision == current.revision and stamp != current.fingerprint\n throw \"Schedule content changed without increasing revision\"\n applyDefinitions(config, schema)\n store = SQL\n insert into lango_schedule_state (id, application, revision, fingerprint)\n values (1, :application, :revision, :fingerprint)\n on conflict (id) do update set revision = excluded.revision,\n fingerprint = excluded.fingerprint, updated_at = now()\n store.application = config.application\n store.revision = config.scheduleRevision\n store.fingerprint = stamp\n store.execute()\n commit_trans()\n catch error\n rollback_trans()\n throw error\n return null\n\ninitializeSchedules(schema)\n state = SQL\n create table if not exists ${schema}.lango_schedule_state (\n id integer primary key check (id = 1), application text not null,\n revision integer not null, fingerprint text not null,\n updated_at timestamptz not null default now()\n )\n state.execute()\n entries = SQL\n create table if not exists ${schema}.lango_schedule_definitions (\n name text primary key, queue text not null, key text not null,\n definition jsonb not null, paused boolean not null default false,\n present boolean not null default true,\n updated_at timestamptz not null default now(), unique (queue, key)\n )\n entries.execute()\n return null\n\noperation(schema, action, queue, key, item = null)\n context db\n input = {\n schema: schema\n action: action\n queue: queue\n key: key\n }\n if item != null\n input.cron = item.cron\n input.payload = {\n version: 1\n application: item.application\n path: item.path\n input: item.data\n source: {\n kind: \"system\"\n identity: item.identity\n }\n failedRetentionSeconds: item.retry.failedRetentionSeconds\n }\n input.options = {\n key: key\n tz: item.timeZone\n missed: item.missed\n precision: item.precision\n retryLimit: item.retry.retryLimit\n retryDelay: item.retry.retryDelay\n retryBackoff: item.retry.retryBackoff\n retryDelayMax: item.retry.retryDelayMax\n expireInSeconds: item.retry.expireInSeconds\n heartbeatSeconds: 30\n deleteAfterSeconds: 0\n }\n return db.invoke({\n module: \"@lango-project/lango-boss/schedule-transaction\"\n handler: \"apply\"\n }, input)\n\napplyDefinitions(config, schema)\n desired = Object/create(null)\n for config.schedules as item\n desired[item.name] = true\n existing = SQL\n select name, queue, key from lango_schedule_definitions where present = true\n existing.execute()\n loop while existing.next()\n if !Object/hasOwn(desired, existing.name)\n operation(schema, \"remove\", existing.queue, existing.key)\n missing = SQL\n update lango_schedule_definitions set present = false, updated_at = now() where name = :name\n missing.name = existing.name\n missing.execute()\n for config.schedules as item\n applyDefinition(config.application, schema, item)\n return null\n\napplyDefinition(application, schema, supplied)\n item = Object/assign({}, supplied, {\n application: application\n })\n key = scheduleKey(application, item.name)\n old = SQL\n select queue, key, paused from lango_schedule_definitions where name = :name\n old.name = item.name\n old.execute()\n found = old.next()\n paused = false\n if found\n paused = old.paused\n moved = found and (old.queue != item.queue or old.key != key)\n if !found or moved\n collision = operation(schema, \"get\", item.queue, key)\n if collision != null\n throw \"Schedule key already exists outside the managed registry: ${item.name}\"\n if moved\n operation(schema, \"remove\", old.queue, old.key)\n if item.enabled and !paused\n operation(schema, \"upsert\", item.queue, key, item)\n else\n operation(schema, \"remove\", item.queue, key)\n store = SQL\n insert into lango_schedule_definitions (name, queue, key, definition)\n values (:name, :queue, :key, :definition::jsonb)\n on conflict (name) do update set queue = excluded.queue, key = excluded.key,\n definition = excluded.definition, present = true, updated_at = now()\n store.name = item.name\n store.queue = item.queue\n store.key = key\n store.definition = to_json(supplied)\n store.execute()\n return null\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA;;;;;;;;;;;AAMA;;;;;;;;;;;;;AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA;;;;;;;;;;;AAkBA;;;;;;;;;;;;;;;;;;;;;;AAuCA;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,24 @@
1
+ import * as pgBoss from "pg-boss";
2
+ import {
3
+ normalize as __normalize,
4
+ boundary as __boundary,
5
+ requireArity as __requireArity,
6
+ } from "./.lango/runtime.mjs";
7
+
8
+ export function apply(db, input) {
9
+ __requireArity(arguments.length, [0, 1], "apply");
10
+ db = __boundary(db);
11
+ input = __boundary(input);
12
+ let boss = new pgBoss.PgBoss({ db: db, schema: __normalize(input.schema), migrate: false, supervise: false, schedule: false, registerInstance: false });
13
+ if (__normalize(input.action) === "get") {
14
+ return __normalize(boss.getSchedule(__normalize(input.queue), __normalize(input.key)));
15
+ } else if (__normalize(input.action) === "remove") {
16
+ return __normalize(boss.unschedule(__normalize(input.queue), __normalize(input.key)));
17
+ } else if (__normalize(input.action) === "upsert") {
18
+ return __normalize(boss.schedule(__normalize(input.queue), __normalize(input.cron), __normalize(input.payload), __normalize(input.options)));
19
+ } else {
20
+ throw "Unknown schedule operation";
21
+ }
22
+ return null;
23
+ }
24
+ //# sourceMappingURL=schedule_transaction.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule_transaction.mjs","sources":["schedule_transaction.lango"],"sourcesContent":["import js \"pg-boss\" as pgBoss\n\nexport apply(db, input)\n\napply(db, input)\n boss = new pgBoss/PgBoss({\n db: db\n schema: input.schema\n migrate: false\n supervise: false\n schedule: false\n registerInstance: false\n })\n switch input.action\n case \"get\"\n return boss.getSchedule(input.queue, input.key)\n case \"remove\"\n return boss.unschedule(input.queue, input.key)\n case \"upsert\"\n return boss.schedule(input.queue, input.cron, input.payload, input.options)\n else\n throw \"Unknown schedule operation\"\n"],"names":[],"mappings":";;;;;;;AAIA;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,201 @@
1
+ import { attributes, empty, integer, boolean, name } from "./validation.mjs";
2
+ import * as cron from "cron-parser";
3
+ import {
4
+ hostGlobal as __hostGlobal,
5
+ xml2obj as __xml2obj,
6
+ fromJson as __fromJson,
7
+ toJson as __toJson,
8
+ isNumber as __isNumber,
9
+ isString as __isString,
10
+ isBool as __isBool,
11
+ isObject as __isObject,
12
+ isArray as __isArray,
13
+ requireBoolean as __requireBoolean,
14
+ normalize as __normalize,
15
+ boundary as __boundary,
16
+ requireArity as __requireArity,
17
+ } from "./.lango/runtime.mjs";
18
+
19
+ function defaults() {
20
+ return { retryLimit: 3, retryDelay: 10, retryBackoff: true, retryDelayMax: 300, expireInSeconds: 900, failedRetentionSeconds: 604800 };
21
+ return null;
22
+ }
23
+
24
+ function retryFields() {
25
+ return ["retryLimit", "retryDelay", "retryBackoff", "retryDelayMax", "expireInSeconds", "failedRetentionSeconds"];
26
+ return null;
27
+ }
28
+
29
+ function retryOptions(spec, base) {
30
+ __requireArity(arguments.length, [0, 1], "retryOptions");
31
+ spec = __boundary(spec);
32
+ base = __boundary(base);
33
+ let result = { retryLimit: integer(__normalize(spec.retryLimit), __normalize(base.retryLimit), 0, 2147483647, "retryLimit"), retryDelay: integer(__normalize(spec.retryDelay), __normalize(base.retryDelay), 1, 2147483647, "retryDelay"), retryBackoff: boolean(__normalize(spec.retryBackoff), __normalize(base.retryBackoff), "retryBackoff"), retryDelayMax: integer(__normalize(spec.retryDelayMax), __normalize(base.retryDelayMax), 1, 2147483647, "retryDelayMax"), expireInSeconds: integer(__normalize(spec.expireInSeconds), __normalize(base.expireInSeconds), 1, 1209600, "expireInSeconds"), failedRetentionSeconds: integer(__normalize(spec.failedRetentionSeconds), __normalize(base.failedRetentionSeconds), 1, 2147483647, "failedRetentionSeconds") };
34
+ if (__requireBoolean(__normalize(result.retryDelay) > __normalize(result.retryDelayMax))) {
35
+ throw "retryDelay cannot exceed retryDelayMax";
36
+ }
37
+ return result;
38
+ return null;
39
+ }
40
+
41
+ function timeZone(value) {
42
+ __requireArity(arguments.length, [0], "timeZone");
43
+ value = __boundary(value);
44
+ let formatter;
45
+ if (__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isString(value))) || __requireBoolean(__normalize(value.trim()) !== value)) || __requireBoolean(value === ""))) {
46
+ throw "A valid time zone is required";
47
+ }
48
+ try {
49
+ formatter = new (__hostGlobal(["Intl"]).DateTimeFormat)("en", { timeZone: value });
50
+ } catch (error) {
51
+ throw `Invalid time zone: ${value}`;
52
+ }
53
+ return value;
54
+ return null;
55
+ }
56
+
57
+ function data(tag) {
58
+ __requireArity(arguments.length, [0], "data");
59
+ tag = __boundary(tag);
60
+ let children = __normalize(tag.children());
61
+ if (__requireBoolean(__normalize(children.length) === 0)) {
62
+ return { };
63
+ }
64
+ if (__requireBoolean(__requireBoolean(__normalize(children.length) !== 1) || __requireBoolean(__normalize(__normalize(children[0]).tag()) !== "data"))) {
65
+ throw "Job may contain only one data element";
66
+ }
67
+ let child = __normalize(children[0]);
68
+ attributes(child, []);
69
+ if (__requireBoolean(__normalize(__normalize(child.children()).length) !== 0)) {
70
+ throw "Job data must contain JSON text";
71
+ }
72
+ let value = null;
73
+ try {
74
+ value = __fromJson(__normalize(child.innerText()));
75
+ } catch (error) {
76
+ throw "Job data must be valid JSON";
77
+ }
78
+ if (__requireBoolean(__requireBoolean(__requireBoolean(value === null) || __requireBoolean(!__requireBoolean(__isObject(value)))) || __requireBoolean(__isArray(value)))) {
79
+ throw "Job data must be a JSON map";
80
+ }
81
+ return value;
82
+ return null;
83
+ }
84
+
85
+ function targetFor(path, targets) {
86
+ __requireArity(arguments.length, [0, 1], "targetFor");
87
+ path = __boundary(path);
88
+ targets = __boundary(targets);
89
+ for (const target of targets) {
90
+ if (__requireBoolean(__normalize(target.path) === path)) {
91
+ return target;
92
+ }
93
+ }
94
+ throw `Unknown job path: ${path}`;
95
+ return null;
96
+ }
97
+
98
+ export function parseSchedules(xml, targets) {
99
+ __requireArity(arguments.length, [0, 1], "parseSchedules");
100
+ xml = __boundary(xml);
101
+ targets = __boundary(targets);
102
+ let parsed = scheduleConfiguration(xml, targets);
103
+ return __normalize(parsed.items);
104
+ return null;
105
+ }
106
+
107
+ export function scheduleConfiguration(xml, targets) {
108
+ __requireArity(arguments.length, [0, 1], "scheduleConfiguration");
109
+ xml = __boundary(xml);
110
+ targets = __boundary(targets);
111
+ let root = __xml2obj(xml);
112
+ if (__requireBoolean(__normalize(root.tag()) !== "jobs")) {
113
+ throw "Expected jobs root";
114
+ }
115
+ attributes(root, ["timeZone", "identity", "revision"]);
116
+ if (__requireBoolean(__normalize(root.revision) === null)) {
117
+ throw "Jobs revision is required";
118
+ }
119
+ let revision = integer(__normalize(root.revision), null, 1, 2147483647, "revision");
120
+ if (__requireBoolean(__normalize(__normalize(root.innerText()).trim()) !== "")) {
121
+ throw "Jobs XML cannot contain text outside data elements";
122
+ }
123
+ let zone = __normalize(root.timeZone);
124
+ if (__requireBoolean(zone === null)) {
125
+ zone = "UTC";
126
+ }
127
+ timeZone(zone);
128
+ let profile = name(__normalize(root.identity), "Jobs identity");
129
+ let base = defaults();
130
+ let seenDefaults = false;
131
+ for (const tag of __normalize(root.children())) {
132
+ if (__requireBoolean(__normalize(tag.tag()) === "defaults")) {
133
+ if (__requireBoolean(seenDefaults)) {
134
+ throw "Duplicate jobs defaults";
135
+ }
136
+ seenDefaults = true;
137
+ attributes(tag, retryFields());
138
+ empty(tag);
139
+ base = retryOptions(__normalize(tag.attributes()), base);
140
+ } else {
141
+ if (__requireBoolean(__normalize(tag.tag()) !== "job")) {
142
+ throw `Unknown jobs element: ${__normalize(tag.tag())}`;
143
+ }
144
+ }
145
+ }
146
+ let seen = __normalize(__hostGlobal(["Object"]).create(null));
147
+ let items = [];
148
+ for (const tag of __normalize(root.children())) {
149
+ if (__requireBoolean(__normalize(tag.tag()) === "defaults")) {
150
+ continue;
151
+ }
152
+ let allowed = ["name", "path", "cron", "timeZone", "missed", "precision", "enabled"];
153
+ for (const field of retryFields()) {
154
+ allowed.push(field);
155
+ }
156
+ attributes(tag, allowed);
157
+ if (__requireBoolean(__normalize(__normalize(tag.innerText()).trim()) !== "")) {
158
+ throw "Job XML cannot contain text outside data";
159
+ }
160
+ let spec = __normalize(tag.attributes());
161
+ let id = name(__normalize(spec.name), "Job name");
162
+ if (__requireBoolean(__normalize(__hostGlobal(["Object"]).hasOwn(seen, id)))) {
163
+ throw `Duplicate job name: ${id}`;
164
+ }
165
+ seen[id] = true;
166
+ let target = targetFor(__normalize(spec.path), targets);
167
+ let selectedZone = zone;
168
+ if (__requireBoolean(__normalize(spec.timeZone) !== null)) {
169
+ selectedZone = timeZone(__normalize(spec.timeZone));
170
+ }
171
+ if (__requireBoolean(__requireBoolean(!__requireBoolean(__isString(__normalize(spec.cron)))) || __requireBoolean(__normalize(spec.cron.trim()) === ""))) {
172
+ throw `Job cron expression is required: ${id}`;
173
+ }
174
+ try {
175
+ __normalize(cron.CronExpressionParser.parse(__normalize(spec.cron), { tz: selectedZone }));
176
+ } catch (error) {
177
+ throw `Invalid job cron expression: ${id}`;
178
+ }
179
+ let missed = __normalize(spec.missed);
180
+ if (__requireBoolean(missed === null)) {
181
+ missed = "skip";
182
+ }
183
+ let missedValues = ["skip", "once"];
184
+ if (__requireBoolean(!__requireBoolean(__normalize(missedValues.includes(missed))))) {
185
+ throw "Job missed must be skip or once";
186
+ }
187
+ let precision = __normalize(spec.precision);
188
+ if (__requireBoolean(precision === null)) {
189
+ precision = "minute";
190
+ }
191
+ let precisions = ["minute", "second"];
192
+ if (__requireBoolean(!__requireBoolean(__normalize(precisions.includes(precision))))) {
193
+ throw "Job precision must be minute or second";
194
+ }
195
+ let retry = retryOptions(spec, base);
196
+ items.push({ name: id, path: __normalize(target.path), queue: __normalize(target.queue), identity: profile, cron: __normalize(spec.cron), timeZone: selectedZone, missed: missed, precision: precision, enabled: boolean(__normalize(spec.enabled), true, "enabled"), data: data(tag), retry: retry });
197
+ }
198
+ return { revision: revision, items: items };
199
+ return null;
200
+ }
201
+ //# sourceMappingURL=schedules.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedules.mjs","sources":["schedules.lango"],"sourcesContent":["import \"./validation\"\n attributes(tag, allowed)\n empty(tag)\n integer(value, fallback, minimum, maximum, name)\n boolean(value, fallback, name)\n name(value, label)\nimport js \"cron-parser\" as cron\nimport js global Intl\nimport js global Object\n\nexport parseSchedules(xml, targets)\nexport scheduleConfiguration(xml, targets)\n\ndefaults()\n return {\n retryLimit: 3\n retryDelay: 10\n retryBackoff: true\n retryDelayMax: 300\n expireInSeconds: 900\n failedRetentionSeconds: 604800\n }\n\nretryFields()\n return [\"retryLimit\", \"retryDelay\", \"retryBackoff\", \"retryDelayMax\", \"expireInSeconds\", \"failedRetentionSeconds\"]\n\nretryOptions(spec, base)\n result = {\n retryLimit: integer(spec.retryLimit, base.retryLimit, 0, 2147483647, \"retryLimit\")\n retryDelay: integer(spec.retryDelay, base.retryDelay, 1, 2147483647, \"retryDelay\")\n retryBackoff: boolean(spec.retryBackoff, base.retryBackoff, \"retryBackoff\")\n retryDelayMax: integer(spec.retryDelayMax, base.retryDelayMax, 1, 2147483647, \"retryDelayMax\")\n expireInSeconds: integer(spec.expireInSeconds, base.expireInSeconds, 1, 1209600, \"expireInSeconds\")\n failedRetentionSeconds: integer(spec.failedRetentionSeconds, base.failedRetentionSeconds, 1, 2147483647, \"failedRetentionSeconds\")\n }\n if result.retryDelay > result.retryDelayMax\n throw \"retryDelay cannot exceed retryDelayMax\"\n return result\n\ntimeZone(value)\n if !is_string(value) or value.trim() != value or value == \"\"\n throw \"A valid time zone is required\"\n try\n formatter = new Intl/DateTimeFormat(\"en\", {\n timeZone: value\n })\n catch error\n throw \"Invalid time zone: ${value}\"\n return value\n\ndata(tag)\n children = tag.children()\n if children.length == 0\n return {}\n if children.length != 1 or children[0].tag() != \"data\"\n throw \"Job may contain only one data element\"\n child = children[0]\n attributes(child, [])\n if child.children().length != 0\n throw \"Job data must contain JSON text\"\n value = null\n try\n value = from_json(child.innerText())\n catch error\n throw \"Job data must be valid JSON\"\n if value == null or !is_object(value) or is_array(value)\n throw \"Job data must be a JSON map\"\n return value\n\ntargetFor(path, targets)\n for targets as target\n if target.path == path\n return target\n throw \"Unknown job path: ${path}\"\n\nparseSchedules(xml, targets)\n parsed = scheduleConfiguration(xml, targets)\n return parsed.items\n\nscheduleConfiguration(xml, targets)\n root = xml2obj(xml)\n if root.tag() != \"jobs\"\n throw \"Expected jobs root\"\n attributes(root, [\"timeZone\", \"identity\", \"revision\"])\n if root.revision == null\n throw \"Jobs revision is required\"\n revision = integer(root.revision, null, 1, 2147483647, \"revision\")\n if root.innerText().trim() != \"\"\n throw \"Jobs XML cannot contain text outside data elements\"\n zone = root.timeZone\n if zone == null\n zone = \"UTC\"\n timeZone(zone)\n profile = name(root.identity, \"Jobs identity\")\n base = defaults()\n seenDefaults = false\n for root.children() as tag\n if tag.tag() == \"defaults\"\n if seenDefaults\n throw \"Duplicate jobs defaults\"\n seenDefaults = true\n attributes(tag, retryFields())\n empty(tag)\n base = retryOptions(tag.attributes(), base)\n else\n if tag.tag() != \"job\"\n throw \"Unknown jobs element: ${tag.tag()}\"\n seen = Object/create(null)\n items = []\n for root.children() as tag\n if tag.tag() == \"defaults\"\n continue\n allowed = [\"name\", \"path\", \"cron\", \"timeZone\", \"missed\", \"precision\", \"enabled\"]\n for retryFields() as field\n allowed.add(field)\n attributes(tag, allowed)\n if tag.innerText().trim() != \"\"\n throw \"Job XML cannot contain text outside data\"\n spec = tag.attributes()\n id = name(spec.name, \"Job name\")\n if Object/hasOwn(seen, id)\n throw \"Duplicate job name: ${id}\"\n seen[id] = true\n target = targetFor(spec.path, targets)\n selectedZone = zone\n if spec.timeZone != null\n selectedZone = timeZone(spec.timeZone)\n if !is_string(spec.cron) or spec.cron.trim() == \"\"\n throw \"Job cron expression is required: ${id}\"\n try\n cron/CronExpressionParser/parse(spec.cron, {\n tz: selectedZone\n })\n catch error\n throw \"Invalid job cron expression: ${id}\"\n missed = spec.missed\n if missed == null\n missed = \"skip\"\n missedValues = [\"skip\", \"once\"]\n if !missedValues.includes(missed)\n throw \"Job missed must be skip or once\"\n precision = spec.precision\n if precision == null\n precision = \"minute\"\n precisions = [\"minute\", \"second\"]\n if !precisions.includes(precision)\n throw \"Job precision must be minute or second\"\n retry = retryOptions(spec, base)\n items.add({\n name: id\n path: target.path\n queue: target.queue\n identity: profile\n cron: spec.cron\n timeZone: selectedZone\n missed: missed\n precision: precision\n enabled: boolean(spec.enabled, true, \"enabled\")\n data: data(tag)\n retry: retry\n })\n return {\n revision: revision\n items: items\n }\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAaA;;;;;AAUA;;;;;AAGA;;;;;;;;;;;;AAaA;;;;;;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA;;;;;;;;;;;;;AAMA;;;;;;;;;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,16 @@
1
+ import * as pgBoss from "pg-boss";
2
+ import {
3
+ normalize as __normalize,
4
+ boundary as __boundary,
5
+ requireArity as __requireArity,
6
+ } from "./.lango/runtime.mjs";
7
+
8
+ export function send(db, input) {
9
+ __requireArity(arguments.length, [0, 1], "send");
10
+ db = __boundary(db);
11
+ input = __boundary(input);
12
+ let boss = new pgBoss.PgBoss({ db: db, schema: __normalize(input.schema), migrate: false, supervise: false, schedule: false, registerInstance: false });
13
+ return __normalize(boss.send(__normalize(input.queue), __normalize(input.payload), { db: db, retryLimit: 3, retryDelay: 10, retryBackoff: true, retryDelayMax: 300, expireInSeconds: 900, heartbeatSeconds: 30, deleteAfterSeconds: 0 }));
14
+ return null;
15
+ }
16
+ //# sourceMappingURL=transaction.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.mjs","sources":["transaction.lango"],"sourcesContent":["import js \"pg-boss\" as pgBoss\n\nexport send(db, input)\n\nsend(db, input)\n boss = new pgBoss/PgBoss({\n db: db\n schema: input.schema\n migrate: false\n supervise: false\n schedule: false\n registerInstance: false\n })\n return boss.send(input.queue, input.payload, {\n db: db\n retryLimit: 3\n retryDelay: 10\n retryBackoff: true\n retryDelayMax: 300\n expireInSeconds: 900\n heartbeatSeconds: 30\n deleteAfterSeconds: 0\n })\n"],"names":[],"mappings":";;;;;;;AAIA;;;;;;;;;"}
@@ -0,0 +1,90 @@
1
+ import {
2
+ hostGlobal as __hostGlobal,
3
+ hostGlobalCall as __hostGlobalCall,
4
+ isNumber as __isNumber,
5
+ isString as __isString,
6
+ isBool as __isBool,
7
+ isObject as __isObject,
8
+ isArray as __isArray,
9
+ entries as __entries,
10
+ requireBoolean as __requireBoolean,
11
+ normalize as __normalize,
12
+ boundary as __boundary,
13
+ requireArity as __requireArity,
14
+ } from "./.lango/runtime.mjs";
15
+
16
+ export function attributes(tag, allowed) {
17
+ __requireArity(arguments.length, [0, 1], "attributes");
18
+ tag = __boundary(tag);
19
+ allowed = __boundary(allowed);
20
+ for (const [key, value] of __entries(__normalize(tag.attributes()))) {
21
+ if (__requireBoolean(!__requireBoolean(__normalize(allowed.includes(key))))) {
22
+ throw `Unknown ${__normalize(tag.tag())} attribute: ${key}`;
23
+ }
24
+ }
25
+ return null;
26
+ return null;
27
+ }
28
+
29
+ export function empty(tag) {
30
+ __requireArity(arguments.length, [0], "empty");
31
+ tag = __boundary(tag);
32
+ if (__requireBoolean(__requireBoolean(__normalize(__normalize(tag.children()).length) !== 0) || __requireBoolean(__normalize(__normalize(tag.innerText()).trim()) !== ""))) {
33
+ throw `Expected an empty ${__normalize(tag.tag())} element`;
34
+ }
35
+ return null;
36
+ return null;
37
+ }
38
+
39
+ export function integer(value, fallback, minimum, maximum, name) {
40
+ __requireArity(arguments.length, [0, 1, 2, 3, 4], "integer");
41
+ value = __boundary(value);
42
+ fallback = __boundary(fallback);
43
+ minimum = __boundary(minimum);
44
+ maximum = __boundary(maximum);
45
+ name = __boundary(name);
46
+ if (__requireBoolean(value === null)) {
47
+ return fallback;
48
+ }
49
+ let pattern = new (__hostGlobal(["RegExp"]))("^[0-9]+$");
50
+ if (__requireBoolean(__requireBoolean(!__requireBoolean(__isString(value))) || __requireBoolean(!__requireBoolean(__normalize(pattern.test(value)))))) {
51
+ throw `${name} must be an integer`;
52
+ }
53
+ let result = __hostGlobalCall(["Number"], value);
54
+ if (__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__normalize(__hostGlobal(["Number"]).isSafeInteger(result)))) || __requireBoolean(result < minimum)) || __requireBoolean(result > maximum))) {
55
+ throw `${name} must be between ${minimum} and ${maximum}`;
56
+ }
57
+ return result;
58
+ return null;
59
+ }
60
+
61
+ export function boolean(value, fallback, name) {
62
+ __requireArity(arguments.length, [0, 1, 2], "boolean");
63
+ value = __boundary(value);
64
+ fallback = __boundary(fallback);
65
+ name = __boundary(name);
66
+ if (__requireBoolean(value === null)) {
67
+ return fallback;
68
+ }
69
+ if (__requireBoolean(__requireBoolean(value !== "true") && __requireBoolean(value !== "false"))) {
70
+ throw `${name} must be true or false`;
71
+ }
72
+ return value === "true";
73
+ return null;
74
+ }
75
+
76
+ export function name(value, label) {
77
+ __requireArity(arguments.length, [0, 1], "name");
78
+ value = __boundary(value);
79
+ label = __boundary(label);
80
+ if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isString(value))) || __requireBoolean(__normalize(value.trim()) !== value)) || __requireBoolean(value === "")) || __requireBoolean(__normalize(value.length) > 200))) {
81
+ throw `${label} must be a nonempty name of at most 200 characters`;
82
+ }
83
+ let pattern = new (__hostGlobal(["RegExp"]))("[\\x00-\\x1f\\x7f]");
84
+ if (__requireBoolean(__normalize(pattern.test(value)))) {
85
+ throw `${label} cannot contain control characters`;
86
+ }
87
+ return value;
88
+ return null;
89
+ }
90
+ //# sourceMappingURL=validation.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.mjs","sources":["validation.lango"],"sourcesContent":["import js global Number\nimport js global RegExp\n\nexport attributes(tag, allowed)\nexport empty(tag)\nexport integer(value, fallback, minimum, maximum, name)\nexport boolean(value, fallback, name)\nexport name(value, label)\n\nattributes(tag, allowed)\n for tag.attributes() as key: value\n if !allowed.includes(key)\n throw \"Unknown ${tag.tag()} attribute: ${key}\"\n return null\n\nempty(tag)\n if tag.children().length != 0 or tag.innerText().trim() != \"\"\n throw \"Expected an empty ${tag.tag()} element\"\n return null\n\ninteger(value, fallback, minimum, maximum, name)\n if value == null\n return fallback\n pattern = new RegExp(\"^[0-9]+$\")\n if !is_string(value) or !pattern.test(value)\n throw \"${name} must be an integer\"\n result = Number(value)\n if !Number/isSafeInteger(result) or result < minimum or result > maximum\n throw \"${name} must be between ${minimum} and ${maximum}\"\n return result\n\nboolean(value, fallback, name)\n if value == null\n return fallback\n if value != \"true\" and value != \"false\"\n throw \"${name} must be true or false\"\n return value == \"true\"\n\nname(value, label)\n if !is_string(value) or value.trim() != value or value == \"\" or value.length > 200\n throw \"${label} must be a nonempty name of at most 200 characters\"\n pattern = new RegExp(\"[\\\\x00-\\\\x1f\\\\x7f]\")\n if pattern.test(value)\n throw \"${label} cannot contain control characters\"\n return value\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AASA;;;;;;;;;;;;;AAMA;;;;;;;;;;AAKA;;;;;;;;;;;;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;AAOA;;;;;;;;;;;;;;;"}