@point-hub/papi 0.5.14 → 0.5.15

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/lib/index.js CHANGED
@@ -71742,6 +71742,37 @@ function mongodbErrorHandlerMiddleware() {
71742
71742
  next(err);
71743
71743
  };
71744
71744
  }
71745
+ // src/database/mongodb/mongodb-compose.ts
71746
+ function composeUpdate(data, parentKey = "") {
71747
+ const updates = { $set: {}, $unset: {} };
71748
+ function isObject2(value) {
71749
+ return typeof value === "object" && value !== null && !Array.isArray(value);
71750
+ }
71751
+ function process2(value, keyPath) {
71752
+ if (value === "" || value === null || value === undefined) {
71753
+ updates.$unset[keyPath] = "";
71754
+ } else if (Array.isArray(value)) {
71755
+ value.forEach((item, index) => {
71756
+ process2(item, `${keyPath}.${index}`);
71757
+ });
71758
+ } else if (isObject2(value)) {
71759
+ Object.entries(value).forEach(([k, v]) => {
71760
+ process2(v, `${keyPath}.${k}`);
71761
+ });
71762
+ } else if (value !== undefined) {
71763
+ updates.$set[keyPath] = value;
71764
+ }
71765
+ }
71766
+ Object.entries(data).forEach(([key, value]) => {
71767
+ const fullKey = parentKey ? `${parentKey}.${key}` : key;
71768
+ process2(value, fullKey);
71769
+ });
71770
+ if (updates.$set && Object.keys(updates.$set).length === 0)
71771
+ delete updates.$set;
71772
+ if (updates.$unset && Object.keys(updates.$unset).length === 0)
71773
+ delete updates.$unset;
71774
+ return updates;
71775
+ }
71745
71776
  // src/test/utils.ts
71746
71777
  class DatabaseTestUtil {
71747
71778
  static dbConnection;
@@ -71900,6 +71931,7 @@ var BaseErrorHandler = {
71900
71931
  };
71901
71932
  export {
71902
71933
  stubDir,
71934
+ composeUpdate,
71903
71935
  DatabaseTestUtil,
71904
71936
  Server as BaseServer,
71905
71937
  BaseMongoServerError,
@@ -0,0 +1,23 @@
1
+ type Primitive = string | number | boolean | null | undefined;
2
+ type Data = Primitive | DataObject | DataArray;
3
+ interface DataObject {
4
+ [key: string]: Data;
5
+ }
6
+ type DataArray = Array<Data>;
7
+ interface MongoUpdate {
8
+ $set?: Record<string, unknown>;
9
+ $unset?: Record<string, string>;
10
+ }
11
+ /**
12
+ * Compose MongoDB update operators ($set and $unset) based on input data.
13
+ * Fields with empty string or null values will be added to $unset,
14
+ * all other fields will be added to $set.
15
+ * Supports nested objects and arrays.
16
+ *
17
+ * @param data - Input object to transform
18
+ * @param parentKey - Internal key path prefix for recursion
19
+ * @returns MongoDB update object with $set and/or $unset
20
+ */
21
+ export declare function composeUpdate(data: DataObject, parentKey?: string): MongoUpdate;
22
+ export {};
23
+ //# sourceMappingURL=mongodb-compose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongodb-compose.d.ts","sourceRoot":"","sources":["../../../../src/database/mongodb/mongodb-compose.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;AAE7D,KAAK,IAAI,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAA;AAC9C,UAAU,UAAU;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CACpB;AACD,KAAK,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,CAAA;AAE5B,UAAU,WAAW;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,SAAK,GAAG,WAAW,CAgC3E"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mongodb-compose.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongodb-compose.spec.d.ts","sourceRoot":"","sources":["../../../../src/database/mongodb/mongodb-compose.spec.ts"],"names":[],"mappings":""}
@@ -11,6 +11,7 @@ export declare const stubDir: string;
11
11
  export { ExpressCli as BaseConsoleCli } from '@point-hub/express-cli';
12
12
  export declare const BaseConsoleCommand: typeof BaseCommand;
13
13
  export declare const BaseConsoleKernel: typeof ConsoleKernel;
14
+ export { composeUpdate } from './database/mongodb/mongodb-compose';
14
15
  export { DatabaseTestUtil } from './test/utils';
15
16
  export declare const BaseDatabaseConnection: typeof DatabaseConnection;
16
17
  export declare const BaseMongoDBConnection: typeof MongoDBConnection;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EACL,QAAQ,EACR,SAAS,EACT,sBAAsB,EACtB,IAAI,EACJ,qBAAqB,EAErB,KAAK,cAAc,EACpB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAA;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AAEjE,OAAO,6BAA6B,MAAM,+CAA+C,CAAA;AAEzF,eAAO,MAAM,OAAO,QAAqF,CAAA;AAGzG,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACrE,eAAO,MAAM,kBAAkB,oBAAc,CAAA;AAC7C,eAAO,MAAM,iBAAiB,sBAAgB,CAAA;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,eAAO,MAAM,sBAAsB,2BAAqB,CAAA;AACxD,eAAO,MAAM,qBAAqB,0BAAoB,CAAA;A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ACjB,SAAS,EACT,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,SAAS,EACT,MAAM,EACN,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,mBAAmB,EACnB,OAAO,EACP,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,EACb,iBAAiB,EACjB,QAAQ,GACT,MAAM,oBAAoB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@point-hub/papi",
3
- "version": "0.5.14",
3
+ "version": "0.5.15",
4
4
  "description": "Point API Framework",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",