@royalschedule/maps 4.0.21 → 4.0.23

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.
@@ -1,4 +1,5 @@
1
1
  import { CoreMap } from "../../core/index.js";
2
+ import { COLLECTION_ID } from "./input/util/util.js";
2
3
  import { parseInput } from "./input/input.js";
3
4
  import { makeConnected } from "../make-connected.js";
4
5
  import { initialConfiguration } from "./initial-configuration.js";
@@ -6,6 +7,15 @@ import { structure } from "../types/to.js";
6
7
  import { pick } from "lodash-es";
7
8
 
8
9
  //#region src/RS/to/schedules.ts
10
+ function transformId(id) {
11
+ const indexOfDot = id.indexOf(".");
12
+ if (indexOfDot == -1) return COLLECTION_ID.events + "." + id;
13
+ const prefix = id.substring(0, indexOfDot).toLowerCase();
14
+ const suffix = id.substring(indexOfDot + 1);
15
+ if (prefix == COLLECTION_ID.lockedTimes.toLowerCase()) return COLLECTION_ID.lockedTimes + "." + suffix;
16
+ if (prefix == COLLECTION_ID.events.toLowerCase()) return COLLECTION_ID.events + "." + suffix;
17
+ throw new Error(`(RS::To::transformId) Unknown id prefix "${prefix}" in id "${id}"`);
18
+ }
9
19
  function schedules(data, _options = {}) {
10
20
  const options = (() => {
11
21
  const x = _options.partialScheduleOptions;
@@ -19,10 +29,7 @@ function schedules(data, _options = {}) {
19
29
  partialScheduleOptions
20
30
  };
21
31
  })();
22
- if (options.partialScheduleOptions?.includedEvents?.size) options.partialScheduleOptions.includedEvents = new Set([...options.partialScheduleOptions.includedEvents].map((x) => {
23
- if (x.startsWith("events.") || x.startsWith("lockedTimes.")) return x;
24
- return `events.${x}`;
25
- }));
32
+ if (options.partialScheduleOptions?.includedEvents?.size) options.partialScheduleOptions.includedEvents = new Set([...options.partialScheduleOptions.includedEvents].map((x) => transformId(x)));
26
33
  const connectedData = makeConnected(data);
27
34
  return {
28
35
  meta: {
@@ -1 +1 @@
1
- {"version":3,"file":"schedules.js","names":["partialScheduleOptions: Types.parsedToOptions['partialScheduleOptions']"],"sources":["../../../src/RS/to/schedules.ts"],"sourcesContent":["import { pick } from 'lodash-es';\nimport { parseInput } from './input/input';\nimport { makeConnected } from '../make-connected';\nimport { initialConfiguration } from './initial-configuration';\nimport type { Types } from '../types';\nimport { CoreMap } from '../../core';\nimport { structure } from '../types/to';\n\nexport function schedules (\n data: Types.toInput,\n _options: Types.toOptions = {}\n): Types.toOutput {\n ////\n //// parse the options\n ////\n const options = ((): Types.parsedToOptions => {\n const x = _options.partialScheduleOptions;\n const partialScheduleOptions: Types.parsedToOptions['partialScheduleOptions'] = x\n ? {\n includedEvents: x.includedEvents ? new Set(x.includedEvents) : undefined,\n includedLocations: x.includedLocations ? new Set(x.includedLocations) : undefined,\n omittedEventsHandling: x.omittedEventsHandling\n }\n : undefined;\n\n return { ..._options, partialScheduleOptions };\n })();\n\n ////\n //// for backward compatibility: add default collection to included events set\n ////\n if (options.partialScheduleOptions?.includedEvents?.size) {\n options.partialScheduleOptions.includedEvents = new Set(\n [...options.partialScheduleOptions.includedEvents]\n .map(x => {\n // should start with 'events.' or 'lockedTimes.' prefix\n if (x.startsWith('events.') || x.startsWith('lockedTimes.')) return x;\n return `events.${x}`;\n })\n );\n }\n\n\n // we will work only with connected schedule data\n const connectedData = makeConnected(data);\n\n return {\n meta: {\n structure: structure,\n division: pick(connectedData.division, 'displayName', 'start', 'end'),\n },\n algorithmParameters: {\n weights: options.algorithmWeightParameters,\n computeTimeMultiplier: options.computeTimeMultiplier\n },\n input: parseInput(connectedData, options),\n ...options.appendCoreData && { coreData: CoreMap.to.schedules(data) },\n ...options.appendOutput && { output: initialConfiguration(connectedData.events, connectedData.lockedTimes, options) },\n };\n};"],"mappings":";;;;;;;;AAQA,SAAgB,UACd,MACA,WAA4B,EAAE,EACd;CAIhB,MAAM,iBAAwC;EAC5C,MAAM,IAAI,SAAS;EACnB,MAAMA,yBAA0E,IAC5E;GACA,gBAAuB,EAAE,iBAAoB,IAAI,IAAI,EAAE,eAAe,GAAM;GAC5E,mBAAuB,EAAE,oBAAoB,IAAI,IAAI,EAAE,kBAAkB,GAAG;GAC5E,uBAAuB,EAAE;GAC1B,GACC;AAEJ,SAAO;GAAE,GAAG;GAAU;GAAwB;KAC5C;AAKJ,KAAI,QAAQ,wBAAwB,gBAAgB,KAClD,SAAQ,uBAAuB,iBAAiB,IAAI,IAClD,CAAC,GAAG,QAAQ,uBAAuB,eAAe,CAC/C,KAAI,MAAK;AAER,MAAI,EAAE,WAAW,UAAU,IAAI,EAAE,WAAW,eAAe,CAAE,QAAO;AACpE,SAAO,UAAU;GACjB,CACL;CAKH,MAAM,gBAAgB,cAAc,KAAK;AAEzC,QAAO;EACL,MAAM;GACO;GACX,UAAW,KAAK,cAAc,UAAU,eAAe,SAAS,MAAM;GACvE;EACD,qBAAqB;GACnB,SAAuB,QAAQ;GAC/B,uBAAuB,QAAQ;GAChC;EACD,OAAO,WAAW,eAAe,QAAQ;EACzC,GAAG,QAAQ,kBAAkB,EAAE,UAAU,QAAQ,GAAG,UAAU,KAAK,EAAE;EACrE,GAAG,QAAQ,gBAAkB,EAAE,QAAQ,qBAAqB,cAAc,QAAQ,cAAc,aAAa,QAAQ,EAAE;EACxH"}
1
+ {"version":3,"file":"schedules.js","names":["partialScheduleOptions: Types.parsedToOptions['partialScheduleOptions']"],"sources":["../../../src/RS/to/schedules.ts"],"sourcesContent":["import { pick } from 'lodash-es';\nimport { parseInput } from './input/input';\nimport { makeConnected } from '../make-connected';\nimport { initialConfiguration } from './initial-configuration';\nimport type { Types } from '../types';\nimport { CoreMap } from '../../core';\nimport { structure } from '../types/to';\nimport { COLLECTION_ID } from './input/util/util';\n\nfunction transformId (id: string): string {\n // should be interpreted as event id\n const indexOfDot = id.indexOf('.');\n if (indexOfDot == -1) return COLLECTION_ID.events + '.' + id;\n\n // split on first dot only\n const prefix = id.substring(0, indexOfDot).toLowerCase();\n const suffix = id.substring(indexOfDot + 1);\n\n if (prefix == COLLECTION_ID.lockedTimes.toLowerCase()) return COLLECTION_ID.lockedTimes + '.' + suffix;\n if (prefix == COLLECTION_ID.events .toLowerCase()) return COLLECTION_ID.events + '.' + suffix;\n\n throw new Error(`(RS::To::transformId) Unknown id prefix \"${prefix}\" in id \"${id}\"`);\n}\n\nexport function schedules (\n data: Types.toInput,\n _options: Types.toOptions = {}\n): Types.toOutput {\n ////\n //// parse the options\n ////\n const options = ((): Types.parsedToOptions => {\n const x = _options.partialScheduleOptions;\n const partialScheduleOptions: Types.parsedToOptions['partialScheduleOptions'] = x\n ? {\n includedEvents: x.includedEvents ? new Set(x.includedEvents) : undefined,\n includedLocations: x.includedLocations ? new Set(x.includedLocations) : undefined,\n omittedEventsHandling: x.omittedEventsHandling\n }\n : undefined;\n\n return { ..._options, partialScheduleOptions };\n })();\n\n ////\n //// for backward compatibility: add default collection to included events set\n ////\n if (options.partialScheduleOptions?.includedEvents?.size) {\n options.partialScheduleOptions.includedEvents = new Set(\n [...options.partialScheduleOptions.includedEvents].map(x => transformId(x))\n );\n }\n\n\n // we will work only with connected schedule data\n const connectedData = makeConnected(data);\n\n return {\n meta: {\n structure: structure,\n division: pick(connectedData.division, 'displayName', 'start', 'end'),\n },\n algorithmParameters: {\n weights: options.algorithmWeightParameters,\n computeTimeMultiplier: options.computeTimeMultiplier\n },\n input: parseInput(connectedData, options),\n ...options.appendCoreData && { coreData: CoreMap.to.schedules(data) },\n ...options.appendOutput && { output: initialConfiguration(connectedData.events, connectedData.lockedTimes, options) },\n };\n};"],"mappings":";;;;;;;;;AASA,SAAS,YAAa,IAAoB;CAExC,MAAM,aAAa,GAAG,QAAQ,IAAI;AAClC,KAAI,cAAc,GAAI,QAAO,cAAc,SAAS,MAAM;CAG1D,MAAM,SAAS,GAAG,UAAU,GAAG,WAAW,CAAC,aAAa;CACxD,MAAM,SAAS,GAAG,UAAU,aAAa,EAAE;AAE3C,KAAI,UAAU,cAAc,YAAY,aAAa,CAAE,QAAO,cAAc,cAAc,MAAM;AAChG,KAAI,UAAU,cAAc,OAAY,aAAa,CAAE,QAAO,cAAc,SAAc,MAAM;AAEhG,OAAM,IAAI,MAAM,4CAA4C,OAAO,WAAW,GAAG,GAAG;;AAGtF,SAAgB,UACd,MACA,WAA4B,EAAE,EACd;CAIhB,MAAM,iBAAwC;EAC5C,MAAM,IAAI,SAAS;EACnB,MAAMA,yBAA0E,IAC5E;GACA,gBAAuB,EAAE,iBAAoB,IAAI,IAAI,EAAE,eAAe,GAAM;GAC5E,mBAAuB,EAAE,oBAAoB,IAAI,IAAI,EAAE,kBAAkB,GAAG;GAC5E,uBAAuB,EAAE;GAC1B,GACC;AAEJ,SAAO;GAAE,GAAG;GAAU;GAAwB;KAC5C;AAKJ,KAAI,QAAQ,wBAAwB,gBAAgB,KAClD,SAAQ,uBAAuB,iBAAiB,IAAI,IAClD,CAAC,GAAG,QAAQ,uBAAuB,eAAe,CAAC,KAAI,MAAK,YAAY,EAAE,CAAC,CAC5E;CAKH,MAAM,gBAAgB,cAAc,KAAK;AAEzC,QAAO;EACL,MAAM;GACO;GACX,UAAW,KAAK,cAAc,UAAU,eAAe,SAAS,MAAM;GACvE;EACD,qBAAqB;GACnB,SAAuB,QAAQ;GAC/B,uBAAuB,QAAQ;GAChC;EACD,OAAO,WAAW,eAAe,QAAQ;EACzC,GAAG,QAAQ,kBAAkB,EAAE,UAAU,QAAQ,GAAG,UAAU,KAAK,EAAE;EACrE,GAAG,QAAQ,gBAAkB,EAAE,QAAQ,qBAAqB,cAAc,QAAQ,cAAc,aAAa,QAAQ,EAAE;EACxH"}
@@ -6,7 +6,7 @@ import { Deep } from "../vertices/index.js";
6
6
 
7
7
  //#region src/core/interfaces/other/policies.d.ts
8
8
  interface Action {
9
- targetResourceModel: string;
9
+ targetResourceModel?: string;
10
10
  operation: (Access['CREATE'] | Access['READ'] | Access['UPDATE'] | Access['DELETE'])[];
11
11
  }
12
12
  interface Statement {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@royalschedule/maps",
3
3
  "description": "",
4
- "version": "4.0.21",
4
+ "version": "4.0.23",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",