pacc 10.3.0 → 10.4.1

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/README.md CHANGED
@@ -83,6 +83,7 @@ tokens "abc" "
83
83
  * [Properties](#properties-1)
84
84
  * [default\_attribute](#default_attribute)
85
85
  * [default\_attribute\_writable](#default_attribute_writable)
86
+ * [default\_collection\_attribute](#default_collection_attribute)
86
87
  * [default\_collection\_attribute\_writable](#default_collection_attribute_writable)
87
88
  * [string\_attribute](#string_attribute)
88
89
  * [string\_attribute\_writable](#string_attribute_writable)
@@ -299,6 +300,7 @@ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Globa
299
300
  * `get` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** get the value can be used to calculate default values
300
301
  * `toInternal` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** 
301
302
  * `toExternal` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** 
303
+ * `asMapEntry` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** deliver key and value for Map insertion
302
304
  * `externalName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** attribute name used by external system
303
305
  * `values` **[Set](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set)\<any>?** allowed values
304
306
  * `env` **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)> | [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))?** environment variable(s) used to provide the value
@@ -315,6 +317,10 @@ Type: [AttributeDefinition](#attributedefinition)
315
317
 
316
318
  Type: [AttributeDefinition](#attributedefinition)
317
319
 
320
+ ## default\_collection\_attribute
321
+
322
+ Type: [AttributeDefinition](#attributedefinition)
323
+
318
324
  ## default\_collection\_attribute\_writable
319
325
 
320
326
  Type: [AttributeDefinition](#attributedefinition)
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "pacc",
3
- "version": "10.3.0",
3
+ "version": "10.4.1",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
7
7
  },
8
- "packageManager": "npm@11.16.0",
8
+ "packageManager": "npm@11.18.0",
9
9
  "types": "./types/module.d.mts",
10
10
  "exports": {
11
11
  ".": {
@@ -43,9 +43,9 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@mitata/counters": "^0.0.8",
46
- "aggregated-map": "^1.0.6",
46
+ "aggregated-map": "^1.0.7",
47
47
  "ava": "^8.0.1",
48
- "browser-ava": "^2.3.63",
48
+ "browser-ava": "^2.3.65",
49
49
  "c8": "^11.0.0",
50
50
  "documentation": "^14.0.3",
51
51
  "mitata": "^1.0.34",
@@ -58,7 +58,7 @@
58
58
  }
59
59
  },
60
60
  "engines": {
61
- "node": ">=26.3.1"
61
+ "node": ">=26.4.0"
62
62
  },
63
63
  "repository": {
64
64
  "type": "git",
@@ -21,6 +21,7 @@ import { types } from "./types.mjs";
21
21
  * @property {Function} [get] get the value can be used to calculate default values
22
22
  * @property {Function} [toInternal]
23
23
  * @property {Function} [toExternal]
24
+ * @property {Function} [asMapEntry] deliver key and value for Map insertion
24
25
  * @property {string} [externalName] attribute name used by external system
25
26
  * @property {Set<any>} [values] allowed values
26
27
  * @property {string[]|string} [env] environment variable(s) used to provide the value
@@ -51,6 +52,14 @@ export const default_attribute_writable = {
51
52
  writable: true
52
53
  };
53
54
 
55
+ /**
56
+ * @type {AttributeDefinition}
57
+ */
58
+ export const default_collection_attribute = {
59
+ ...default_attribute,
60
+ collection: true
61
+ };
62
+
54
63
  /**
55
64
  * @type {AttributeDefinition}
56
65
  */
package/src/expand.mjs CHANGED
@@ -2,6 +2,8 @@ import { parse } from "./parser.mjs";
2
2
 
3
3
  const maxNestingLevel = 8;
4
4
 
5
+ class _Dummy {}
6
+
5
7
  /**
6
8
  * Default expand context
7
9
  * using '§{' and '}' as lead in/out
@@ -9,7 +11,8 @@ const maxNestingLevel = 8;
9
11
  export const expandContextDefault = {
10
12
  root: {},
11
13
  leadIn: "${",
12
- leadOut: "}"
14
+ leadOut: "}",
15
+ stopClass: _Dummy
13
16
  };
14
17
 
15
18
  /**
@@ -26,7 +29,7 @@ export const expandContextDoubbleCurly = {
26
29
  * @param {any} object
27
30
  * @param {Object} context
28
31
  * @param {any} [context.root] actual replacement values
29
- * @param {function} [context.stopClass]
32
+ * @param {function} [context.stopClass] do not expand instancif
30
33
  * @param {string} [context.leadIn] starting separator
31
34
  * @param {string} [context.leadOut] ending separator
32
35
  * @returns {any|Promise<any>}
@@ -140,6 +143,7 @@ export function expand(object, context) {
140
143
 
141
144
  if (typeof object.entries === "function") {
142
145
  const copy = new object.constructor[Symbol.species]();
146
+
143
147
  for (const [key, value] of object.entries()) {
144
148
  const path2 = [
145
149
  ...path,
@@ -155,11 +159,11 @@ export function expand(object, context) {
155
159
  return copy;
156
160
  }
157
161
 
158
- if (context.stopClass && object instanceof context.stopClass) {
162
+ if (object instanceof context.stopClass) {
159
163
  return object;
160
164
  }
161
165
 
162
- if(Object.prototype.toString.call(object) !== '[object Object]') {
166
+ if (Object.prototype.toString.call(object) !== "[object Object]") {
163
167
  return object;
164
168
  }
165
169
 
package/src/extract.mjs CHANGED
@@ -19,19 +19,18 @@ export function extract(object, type = object.constructor) {
19
19
  result[name] = value;
20
20
  }
21
21
  } else {
22
- const key = value.constructor.key;
23
-
24
22
  if (attribute.backpointer) {
25
23
  if (attribute.collection) {
26
24
  if ((value.size ?? value.length) > 0) {
27
25
  result[name] = Object.fromEntries(
28
- [...value.values()].map(v => [v[key], v])
26
+ [...value.values()].map(v => [v[v.constructor.key], extract(v)])
29
27
  );
30
28
  }
31
29
  } else {
32
30
  result[name] = extract(value);
33
31
  }
34
32
  } else {
33
+ const key = value.constructor.key;
35
34
  result[name] = { [key]: value[key], type: value.constructor.name };
36
35
  }
37
36
  }
@@ -19,6 +19,7 @@
19
19
  * @property {Function} [get] get the value can be used to calculate default values
20
20
  * @property {Function} [toInternal]
21
21
  * @property {Function} [toExternal]
22
+ * @property {Function} [asMapEntry] deliver key and value for Map insertion
22
23
  * @property {string} [externalName] attribute name used by external system
23
24
  * @property {Set<any>} [values] allowed values
24
25
  * @property {string[]|string} [env] environment variable(s) used to provide the value
@@ -34,6 +35,10 @@ export const default_attribute: AttributeDefinition;
34
35
  * @type {AttributeDefinition}
35
36
  */
36
37
  export const default_attribute_writable: AttributeDefinition;
38
+ /**
39
+ * @type {AttributeDefinition}
40
+ */
41
+ export const default_collection_attribute: AttributeDefinition;
37
42
  /**
38
43
  * @type {AttributeDefinition}
39
44
  */
@@ -144,6 +149,7 @@ export namespace yesno_attribute_writable {
144
149
  export let get: Function | undefined;
145
150
  export let toInternal: Function | undefined;
146
151
  export let toExternal: Function | undefined;
152
+ export let asMapEntry: Function | undefined;
147
153
  export let externalName: string | undefined;
148
154
  export let values: Set<any> | undefined;
149
155
  export let env: string | string[] | undefined;
@@ -339,6 +345,10 @@ export type AttributeDefinition = {
339
345
  get?: Function | undefined;
340
346
  toInternal?: Function | undefined;
341
347
  toExternal?: Function | undefined;
348
+ /**
349
+ * deliver key and value for Map insertion
350
+ */
351
+ asMapEntry?: Function | undefined;
342
352
  /**
343
353
  * attribute name used by external system
344
354
  */
@@ -3,7 +3,7 @@
3
3
  * @param {any} object
4
4
  * @param {Object} context
5
5
  * @param {any} [context.root] actual replacement values
6
- * @param {function} [context.stopClass]
6
+ * @param {function} [context.stopClass] do not expand instancif
7
7
  * @param {string} [context.leadIn] starting separator
8
8
  * @param {string} [context.leadOut] ending separator
9
9
  * @returns {any|Promise<any>}
@@ -15,9 +15,10 @@ export function expand(object: any, context: {
15
15
  leadOut?: string | undefined;
16
16
  }): any | Promise<any>;
17
17
  export namespace expandContextDefault {
18
- let root: {};
19
- let leadIn: string;
20
- let leadOut: string;
18
+ export let root: {};
19
+ export let leadIn: string;
20
+ export let leadOut: string;
21
+ export { _Dummy as stopClass };
21
22
  }
22
23
  export namespace expandContextDoubbleCurly {
23
24
  let leadIn_1: string;
@@ -25,3 +26,6 @@ export namespace expandContextDoubbleCurly {
25
26
  let leadOut_1: string;
26
27
  export { leadOut_1 as leadOut };
27
28
  }
29
+ declare class _Dummy {
30
+ }
31
+ export {};