corebasic 1.0.203 → 1.0.205

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.
package/libs/dip.js CHANGED
@@ -17,6 +17,8 @@ export const globalMeta = Elabase.globalMeta
17
17
  export const companyMeta = Elabase.companyMeta
18
18
  export const outletMeta = Elabase.outletMeta
19
19
  export const customMeta = Elabase.customMeta
20
+ export const schema = Elabase.schema
21
+ export const isDipMeta = Elabase.isDipMeta
20
22
 
21
23
  export const shard_stats = Elabase.shard_stats
22
24
  export let config = Elabase.config
@@ -87,7 +89,7 @@ export const idip = async (message, callback, cleanup) => {
87
89
 
88
90
 
89
91
  export const insertKeys = (message, meta) => {
90
- if (!(meta instanceof DipMeta)) throw {message: 'Error: Provided meta is not an instance of DipMeta in Dip.insertKeys()'}
92
+ if (!isDipMeta(meta)) throw {message: 'Error: Provided meta is not an instance of DipMeta in Dip.insertKeys()'}
91
93
  return {
92
94
  "created": message.date, "updated": message.date,
93
95
  "createdBy": message.meta.staff,
package/libs/elabase.js CHANGED
@@ -67,7 +67,7 @@ class DipMeta {
67
67
  Object.freeze(this);
68
68
  }
69
69
  }
70
-
70
+ export const isDipMeta = meta => meta instanceof DipMeta
71
71
 
72
72
  export const globalMeta = args => {
73
73
  return new DipMeta({ ...args, company: "GLOBAL", outlet: "GLOBAL" })
@@ -219,6 +219,21 @@ export function batchSubmit(batch_id, arg) {
219
219
  })
220
220
  }
221
221
 
222
+ const SCHEMAS_JSON_PROMISES = {}
223
+ export const schema = async (name) => {
224
+ // Cache the loading promise right away so parallel requests share it
225
+ if (!SCHEMAS_JSON_PROMISES[name])
226
+ SCHEMAS_JSON_PROMISES[name] = Utils.fileToJson(new URL('../../..', import.meta.url), `schemas/${name}.json`)
227
+
228
+ try {
229
+ const schema = await SCHEMAS_JSON_PROMISES[name];
230
+ return structuredClone(schema)
231
+ } catch (e) {
232
+ // Delete the broken promise from cache so a retry can occur later
233
+ delete SCHEMAS_JSON_PROMISES[name]
234
+ throw {message: `Error: Failed to load schema ${name} in Dip`}
235
+ }
236
+ }
222
237
 
223
238
  const COLLECTIONS_JSON = await (async () => {
224
239
  try {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.203",
4
+ "version": "1.0.205",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {