@aeriajs/common 0.0.0

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.
Files changed (66) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +13 -0
  3. package/dist/arraysIntersects.d.ts +1 -0
  4. package/dist/arraysIntersects.js +12 -0
  5. package/dist/arraysIntersects.mjs +8 -0
  6. package/dist/checkForUndefined.d.ts +2 -0
  7. package/dist/checkForUndefined.js +12 -0
  8. package/dist/checkForUndefined.mjs +6 -0
  9. package/dist/convertConditionToQuery.d.ts +2 -0
  10. package/dist/convertConditionToQuery.js +60 -0
  11. package/dist/convertConditionToQuery.mjs +72 -0
  12. package/dist/date.d.ts +7 -0
  13. package/dist/date.js +42 -0
  14. package/dist/date.mjs +101 -0
  15. package/dist/deepClone.d.ts +1 -0
  16. package/dist/deepClone.js +9 -0
  17. package/dist/deepClone.mjs +3 -0
  18. package/dist/deepMerge.d.ts +5 -0
  19. package/dist/deepMerge.js +39 -0
  20. package/dist/deepMerge.mjs +66 -0
  21. package/dist/dynamicImport.d.ts +1 -0
  22. package/dist/dynamicImport.js +16 -0
  23. package/dist/dynamicImport.mjs +145 -0
  24. package/dist/either.d.ts +9 -0
  25. package/dist/either.js +37 -0
  26. package/dist/either.mjs +32 -0
  27. package/dist/evaluateCondition.d.ts +5 -0
  28. package/dist/evaluateCondition.js +57 -0
  29. package/dist/evaluateCondition.mjs +63 -0
  30. package/dist/formatValue.d.ts +2 -0
  31. package/dist/formatValue.js +55 -0
  32. package/dist/formatValue.mjs +59 -0
  33. package/dist/freshItem.d.ts +2 -0
  34. package/dist/freshItem.js +36 -0
  35. package/dist/freshItem.mjs +133 -0
  36. package/dist/getMissingProperties.d.ts +2 -0
  37. package/dist/getMissingProperties.js +38 -0
  38. package/dist/getMissingProperties.mjs +50 -0
  39. package/dist/getReferenceProperty.d.ts +2 -0
  40. package/dist/getReferenceProperty.js +19 -0
  41. package/dist/getReferenceProperty.mjs +11 -0
  42. package/dist/getValueFromPath.d.ts +1 -0
  43. package/dist/getValueFromPath.js +10 -0
  44. package/dist/getValueFromPath.mjs +6 -0
  45. package/dist/http.d.ts +20 -0
  46. package/dist/http.js +51 -0
  47. package/dist/http.mjs +224 -0
  48. package/dist/index.d.ts +20 -0
  49. package/dist/index.js +36 -0
  50. package/dist/index.mjs +20 -0
  51. package/dist/isReference.d.ts +2 -0
  52. package/dist/isReference.js +9 -0
  53. package/dist/isReference.mjs +3 -0
  54. package/dist/isRequired.d.ts +2 -0
  55. package/dist/isRequired.js +18 -0
  56. package/dist/isRequired.mjs +14 -0
  57. package/dist/pipe.d.ts +4 -0
  58. package/dist/pipe.js +28 -0
  59. package/dist/pipe.mjs +259 -0
  60. package/dist/schema.d.ts +20 -0
  61. package/dist/schema.js +74 -0
  62. package/dist/schema.mjs +72 -0
  63. package/dist/serialize.d.ts +3 -0
  64. package/dist/serialize.js +33 -0
  65. package/dist/serialize.mjs +38 -0
  66. package/package.json +37 -0
package/dist/pipe.mjs ADDED
@@ -0,0 +1,259 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_without_holes(arr) {
7
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
8
+ }
9
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
10
+ try {
11
+ var info = gen[key](arg);
12
+ var value = info.value;
13
+ } catch (error) {
14
+ reject(error);
15
+ return;
16
+ }
17
+ if (info.done) {
18
+ resolve(value);
19
+ } else {
20
+ Promise.resolve(value).then(_next, _throw);
21
+ }
22
+ }
23
+ function _async_to_generator(fn) {
24
+ return function() {
25
+ var self = this, args = arguments;
26
+ return new Promise(function(resolve, reject) {
27
+ var gen = fn.apply(self, args);
28
+ function _next(value) {
29
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
30
+ }
31
+ function _throw(err) {
32
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
33
+ }
34
+ _next(undefined);
35
+ });
36
+ };
37
+ }
38
+ function _iterable_to_array(iter) {
39
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
40
+ }
41
+ function _non_iterable_spread() {
42
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
43
+ }
44
+ function _to_consumable_array(arr) {
45
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
46
+ }
47
+ function _type_of(obj) {
48
+ "@swc/helpers - typeof";
49
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
50
+ }
51
+ function _unsupported_iterable_to_array(o, minLen) {
52
+ if (!o) return;
53
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
54
+ var n = Object.prototype.toString.call(o).slice(8, -1);
55
+ if (n === "Object" && o.constructor) n = o.constructor.name;
56
+ if (n === "Map" || n === "Set") return Array.from(n);
57
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
58
+ }
59
+ function _ts_generator(thisArg, body) {
60
+ var f, y, t, g, _ = {
61
+ label: 0,
62
+ sent: function() {
63
+ if (t[0] & 1) throw t[1];
64
+ return t[1];
65
+ },
66
+ trys: [],
67
+ ops: []
68
+ };
69
+ return g = {
70
+ next: verb(0),
71
+ "throw": verb(1),
72
+ "return": verb(2)
73
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
74
+ return this;
75
+ }), g;
76
+ function verb(n) {
77
+ return function(v) {
78
+ return step([
79
+ n,
80
+ v
81
+ ]);
82
+ };
83
+ }
84
+ function step(op) {
85
+ if (f) throw new TypeError("Generator is already executing.");
86
+ while(_)try {
87
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
88
+ if (y = 0, t) op = [
89
+ op[0] & 2,
90
+ t.value
91
+ ];
92
+ switch(op[0]){
93
+ case 0:
94
+ case 1:
95
+ t = op;
96
+ break;
97
+ case 4:
98
+ _.label++;
99
+ return {
100
+ value: op[1],
101
+ done: false
102
+ };
103
+ case 5:
104
+ _.label++;
105
+ y = op[1];
106
+ op = [
107
+ 0
108
+ ];
109
+ continue;
110
+ case 7:
111
+ op = _.ops.pop();
112
+ _.trys.pop();
113
+ continue;
114
+ default:
115
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
116
+ _ = 0;
117
+ continue;
118
+ }
119
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
120
+ _.label = op[1];
121
+ break;
122
+ }
123
+ if (op[0] === 6 && _.label < t[1]) {
124
+ _.label = t[1];
125
+ t = op;
126
+ break;
127
+ }
128
+ if (t && _.label < t[2]) {
129
+ _.label = t[2];
130
+ _.ops.push(op);
131
+ break;
132
+ }
133
+ if (t[2]) _.ops.pop();
134
+ _.trys.pop();
135
+ continue;
136
+ }
137
+ op = body.call(thisArg, _);
138
+ } catch (e) {
139
+ op = [
140
+ 6,
141
+ e
142
+ ];
143
+ y = 0;
144
+ } finally{
145
+ f = t = 0;
146
+ }
147
+ if (op[0] & 5) throw op[1];
148
+ return {
149
+ value: op[0] ? op[1] : void 0,
150
+ done: true
151
+ };
152
+ }
153
+ }
154
+ export var pipe = function(functions, options) {
155
+ var returnFirst = (options || {}).returnFirst;
156
+ return function() {
157
+ var _ref = _async_to_generator(function(value) {
158
+ var _len, args, _key, ret, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, fn, result, err;
159
+ var _arguments = arguments;
160
+ return _ts_generator(this, function(_state) {
161
+ switch(_state.label){
162
+ case 0:
163
+ for(_len = _arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
164
+ args[_key - 1] = _arguments[_key];
165
+ }
166
+ ret = value;
167
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
168
+ _state.label = 1;
169
+ case 1:
170
+ _state.trys.push([
171
+ 1,
172
+ 6,
173
+ 7,
174
+ 8
175
+ ]);
176
+ _iterator = functions[Symbol.iterator]();
177
+ _state.label = 2;
178
+ case 2:
179
+ if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
180
+ 3,
181
+ 5
182
+ ];
183
+ fn = _step.value;
184
+ return [
185
+ 4,
186
+ fn.apply(void 0, [
187
+ ret
188
+ ].concat(_to_consumable_array(args)))
189
+ ];
190
+ case 3:
191
+ ret = _state.sent();
192
+ if (returnFirst && ret !== undefined) {
193
+ switch(typeof returnFirst === "undefined" ? "undefined" : _type_of(returnFirst)){
194
+ case "function":
195
+ {
196
+ result = returnFirst(ret);
197
+ if (result) {
198
+ return [
199
+ 2,
200
+ result
201
+ ];
202
+ }
203
+ break;
204
+ }
205
+ default:
206
+ {
207
+ return [
208
+ 2,
209
+ ret
210
+ ];
211
+ }
212
+ }
213
+ }
214
+ _state.label = 4;
215
+ case 4:
216
+ _iteratorNormalCompletion = true;
217
+ return [
218
+ 3,
219
+ 2
220
+ ];
221
+ case 5:
222
+ return [
223
+ 3,
224
+ 8
225
+ ];
226
+ case 6:
227
+ err = _state.sent();
228
+ _didIteratorError = true;
229
+ _iteratorError = err;
230
+ return [
231
+ 3,
232
+ 8
233
+ ];
234
+ case 7:
235
+ try {
236
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
237
+ _iterator.return();
238
+ }
239
+ } finally{
240
+ if (_didIteratorError) {
241
+ throw _iteratorError;
242
+ }
243
+ }
244
+ return [
245
+ 7
246
+ ];
247
+ case 8:
248
+ return [
249
+ 2,
250
+ ret
251
+ ];
252
+ }
253
+ });
254
+ });
255
+ return function(value) {
256
+ return _ref.apply(this, arguments);
257
+ };
258
+ }();
259
+ };
@@ -0,0 +1,20 @@
1
+ import { type Property, type ObjectToSchema } from '@aeriajs/types';
2
+ export declare const fromLiteral: <const TObject, TRequired extends (keyof TObject & string)[]>(object: TObject, required?: TRequired | undefined) => ObjectToSchema<TObject, TRequired>;
3
+ export declare const leftSchema: <const TObject extends Property>(object: TObject) => {
4
+ type: "object";
5
+ properties: {
6
+ _tag: {
7
+ literal: string;
8
+ };
9
+ value: Property;
10
+ };
11
+ };
12
+ export declare const rightSchema: <const TObject extends Property>(object: TObject) => {
13
+ type: "object";
14
+ properties: {
15
+ _tag: {
16
+ literal: string;
17
+ };
18
+ value: Property;
19
+ };
20
+ };
package/dist/schema.js ADDED
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rightSchema = exports.leftSchema = exports.fromLiteral = void 0;
4
+ const mapValueToProperty = (value) => {
5
+ if (value.constructor === Object) {
6
+ return Object.assign({
7
+ type: 'object',
8
+ }, (0, exports.fromLiteral)(value));
9
+ }
10
+ if (value === Date) {
11
+ return {
12
+ type: 'string',
13
+ format: 'date-time',
14
+ };
15
+ }
16
+ if (Array.isArray(value)) {
17
+ return {
18
+ type: 'array',
19
+ items: mapValueToProperty(value[0]),
20
+ };
21
+ }
22
+ if (value && typeof value === 'string') {
23
+ return {
24
+ $ref: value,
25
+ };
26
+ }
27
+ return {
28
+ type: typeof value,
29
+ };
30
+ };
31
+ const fromLiteral = (object, required) => {
32
+ const entries = [];
33
+ for (const propName in object) {
34
+ const value = object[propName];
35
+ if (value === null || value === undefined) {
36
+ continue;
37
+ }
38
+ entries.push([
39
+ propName,
40
+ mapValueToProperty(value),
41
+ ]);
42
+ }
43
+ const properties = Object.fromEntries(entries);
44
+ return {
45
+ type: 'object',
46
+ required,
47
+ properties,
48
+ };
49
+ };
50
+ exports.fromLiteral = fromLiteral;
51
+ const leftSchema = (object) => {
52
+ return {
53
+ type: 'object',
54
+ properties: {
55
+ _tag: {
56
+ literal: 'Left',
57
+ },
58
+ value: object,
59
+ },
60
+ };
61
+ };
62
+ exports.leftSchema = leftSchema;
63
+ const rightSchema = (object) => {
64
+ return {
65
+ type: 'object',
66
+ properties: {
67
+ _tag: {
68
+ literal: 'Right',
69
+ },
70
+ value: object,
71
+ },
72
+ };
73
+ };
74
+ exports.rightSchema = rightSchema;
@@ -0,0 +1,72 @@
1
+ function _type_of(obj) {
2
+ "@swc/helpers - typeof";
3
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
4
+ }
5
+ var mapValueToProperty = function(value) {
6
+ if (value.constructor === Object) {
7
+ return Object.assign({
8
+ type: "object"
9
+ }, fromLiteral(value));
10
+ }
11
+ if (value === Date) {
12
+ return {
13
+ type: "string",
14
+ format: "date-time"
15
+ };
16
+ }
17
+ if (Array.isArray(value)) {
18
+ return {
19
+ type: "array",
20
+ items: mapValueToProperty(value[0])
21
+ };
22
+ }
23
+ if (value && typeof value === "string") {
24
+ return {
25
+ $ref: value
26
+ };
27
+ }
28
+ return {
29
+ type: typeof value === "undefined" ? "undefined" : _type_of(value)
30
+ };
31
+ };
32
+ export var fromLiteral = function(object, required) {
33
+ var entries = [];
34
+ for(var propName in object){
35
+ var value = object[propName];
36
+ if (value === null || value === undefined) {
37
+ continue;
38
+ }
39
+ entries.push([
40
+ propName,
41
+ mapValueToProperty(value)
42
+ ]);
43
+ }
44
+ var properties = Object.fromEntries(entries);
45
+ return {
46
+ type: "object",
47
+ required: required,
48
+ properties: properties
49
+ };
50
+ };
51
+ export var leftSchema = function(object) {
52
+ return {
53
+ type: "object",
54
+ properties: {
55
+ _tag: {
56
+ literal: "Left"
57
+ },
58
+ value: object
59
+ }
60
+ };
61
+ };
62
+ export var rightSchema = function(object) {
63
+ return {
64
+ type: "object",
65
+ properties: {
66
+ _tag: {
67
+ literal: "Right"
68
+ },
69
+ value: object
70
+ }
71
+ };
72
+ };
@@ -0,0 +1,3 @@
1
+ import * as BSON from 'bson';
2
+ export declare const serialize: (object: BSON.Document, options?: BSON.SerializeOptions | undefined) => string;
3
+ export declare const deserialize: <T extends string>(buffer: T) => BSON.Document;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.deserialize = exports.serialize = void 0;
27
+ const BSON = __importStar(require("bson"));
28
+ const serialize = (...args) => Buffer.from(BSON.serialize(...args)).toString('latin1');
29
+ exports.serialize = serialize;
30
+ const deserialize = (buffer) => {
31
+ return BSON.deserialize(new Uint8Array(Array.from(buffer).map((c) => c.charCodeAt(0))));
32
+ };
33
+ exports.deserialize = deserialize;
@@ -0,0 +1,38 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_without_holes(arr) {
7
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
8
+ }
9
+ function _iterable_to_array(iter) {
10
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
11
+ }
12
+ function _non_iterable_spread() {
13
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14
+ }
15
+ function _to_consumable_array(arr) {
16
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
17
+ }
18
+ function _unsupported_iterable_to_array(o, minLen) {
19
+ if (!o) return;
20
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
21
+ var n = Object.prototype.toString.call(o).slice(8, -1);
22
+ if (n === "Object" && o.constructor) n = o.constructor.name;
23
+ if (n === "Map" || n === "Set") return Array.from(n);
24
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
25
+ }
26
+ var _BSON;
27
+ import * as BSON from "bson";
28
+ export var serialize = function() {
29
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
30
+ args[_key] = arguments[_key];
31
+ }
32
+ return Buffer.from((_BSON = BSON).serialize.apply(_BSON, _to_consumable_array(args))).toString("latin1");
33
+ };
34
+ export var deserialize = function(buffer) {
35
+ return BSON.deserialize(new Uint8Array(Array.from(buffer).map(function(c) {
36
+ return c.charCodeAt(0);
37
+ })));
38
+ };
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@aeriajs/common",
3
+ "version": "0.0.0",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "keywords": [],
12
+ "author": "",
13
+ "license": "ISC",
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "exports": {
18
+ ".": {
19
+ "import": "./dist/index.mjs",
20
+ "require": "./dist/index.js",
21
+ "types": "./dist/index.d.ts"
22
+ }
23
+ },
24
+ "peerDependencies": {
25
+ "@aeriajs/types": "^0.0.0",
26
+ "bson": "^5.4.0"
27
+ },
28
+ "scripts": {
29
+ "test": "echo skipping",
30
+ "lint": "eslint src",
31
+ "lint:fix": "eslint src --fix",
32
+ "build": "pnpm build:cjs && pnpm build:esm",
33
+ "build:cjs": "tsc",
34
+ "build:esm": "swc src/* -d dist --strip-leading-paths -C module.type=es6 --out-file-extension=mjs && pnpm build:esm-transform",
35
+ "build:esm-transform": "pnpm -w esm-transform $PWD/dist"
36
+ }
37
+ }