corebasic 1.0.208 → 1.0.210

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.
@@ -136,18 +136,22 @@ export function matchPolicy(query, when, g_obj) {
136
136
 
137
137
 
138
138
 
139
- export async function applySuffixPolicy(COLLECTIONS_JSON, collection, query) {
140
- const collection_policy = COLLECTIONS_JSON[collection]?.policy ?? []
141
- const suffixPolicies = typeof collection_policy === "object" && !Array.isArray(collection_policy) ? [collection_policy] : COLLECTIONS_JSON[collection]?.policy ?? []
139
+ export async function applySuffixPolicy(COLLECTIONS_JSON, collections, query, insertMode, arg) {
140
+ collections = Array.isArray(collections) ? collections : [collections]
142
141
  let suffixes = []
143
- for (const policy of suffixPolicies) {
144
- if (matchPolicy(query, policy.when ?? {})) {
145
- // generate suffixes
146
- const array = await suffix(query, policy.suffix ?? [])
147
- suffixes.push(...array)
142
+
143
+ for (let collection of collections) {
144
+ const collection_policy = COLLECTIONS_JSON[collection]?.policy ?? []
145
+ const suffixPolicies = typeof collection_policy === "object" && !Array.isArray(collection_policy) ? [collection_policy] : COLLECTIONS_JSON[collection]?.policy ?? []
146
+ for (const policy of suffixPolicies) {
147
+ if (matchPolicy(query, policy.when ?? {})) {
148
+ // generate suffixes
149
+ const array = await suffix(query, policy.suffix ?? [], insertMode, arg)
150
+ suffixes.push(...array)
151
+ }
148
152
  }
153
+ suffixes = [...new Set(suffixes)];
149
154
  }
150
- suffixes = [...new Set(suffixes)];
151
155
  return suffixes
152
156
  }
153
157
 
@@ -47,6 +47,8 @@ export async function suffix(doc, policies, insertMode, arg) {
47
47
  console.warn(`Warn: Missing suffix policy min/max bound for ${policy_type} range specified for key ${policy.key} in Dip`)
48
48
  } else {
49
49
  ranges = fillDates({from, to, fromOp, toOp}, format)
50
+ if (!ranges.length && policy.inferRange)
51
+ ranges = [...new Set([from === undefined ? undefined : formatDate(from, format), to === undefined ? undefined : formatDate(to, format)].filter(item => item))]
50
52
  // console.log(ranges)
51
53
  if (ranges.length > ls_threshold) {
52
54
  keys = [] // Too many suffixes to enumerate. Fall back to Dip.operation("ls").
package/libs/elabase.js CHANGED
@@ -97,7 +97,7 @@ export const customMeta = (company, outlet, args) => {
97
97
  throw new Error("Error: Invalid outlet provided in Dip.customMeta()")
98
98
 
99
99
  if (!company || (typeof company === "string" && company.trim() === "") || company === "GLOBAL" || (Array.isArray(company) && (!company.length || company.some(item => typeof item !== "string" || item.trim() === "" || item === "GLOBAL")) ))
100
- throw new Error("Error: Invalid company provided in Dip.customMeta()"}
100
+ throw new Error("Error: Invalid company provided in Dip.customMeta()")
101
101
  if (!outlet || (typeof outlet === "string" && outlet.trim() === "") || outlet === "GLOBAL" || (Array.isArray(outlet) && (!outlet.length || outlet.some(item => typeof item !== "string" || item.trim() === "" || item === "GLOBAL")) ))
102
102
  throw new Error("Error: Invalid outlet provided in Dip.customMeta()")
103
103
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.208",
4
+ "version": "1.0.210",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {