ag-common 0.0.894 → 0.0.896
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/LICENSE.md +2 -3
- package/README.md +2 -2
- package/dist/api/helpers/acm.d.ts +1 -1
- package/dist/api/helpers/acm.js +3 -3
- package/dist/api/helpers/api.d.ts +2 -2
- package/dist/api/helpers/api.js +26 -22
- package/dist/api/helpers/apigw.js +4 -4
- package/dist/api/helpers/aws.js +2 -2
- package/dist/api/helpers/cosmos/delete.d.ts +1 -1
- package/dist/api/helpers/cosmos/delete.js +15 -16
- package/dist/api/helpers/cosmos/get.d.ts +3 -3
- package/dist/api/helpers/cosmos/get.js +26 -32
- package/dist/api/helpers/cosmos/index.d.ts +3 -3
- package/dist/api/helpers/cosmos/index.js +1 -1
- package/dist/api/helpers/cosmos/utils.d.ts +1 -1
- package/dist/api/helpers/cosmos/utils.js +3 -7
- package/dist/api/helpers/cosmos/write.d.ts +1 -1
- package/dist/api/helpers/cosmos/write.js +11 -12
- package/dist/api/helpers/dynamo/delete.d.ts +1 -1
- package/dist/api/helpers/dynamo/delete.js +3 -3
- package/dist/api/helpers/dynamo/get.d.ts +2 -2
- package/dist/api/helpers/dynamo/get.js +20 -14
- package/dist/api/helpers/dynamo/index.d.ts +10 -38
- package/dist/api/helpers/dynamo/index.js +4 -4
- package/dist/api/helpers/dynamo/set.d.ts +1 -1
- package/dist/api/helpers/dynamo/set.js +10 -10
- package/dist/api/helpers/dynamo/types.d.ts +3 -3
- package/dist/api/helpers/dynamo/types.js +1 -1
- package/dist/api/helpers/enforceDynamoProvisionCap.d.ts +13 -1
- package/dist/api/helpers/enforceDynamoProvisionCap.js +3 -4
- package/dist/api/helpers/google/apikey.js +1 -1
- package/dist/api/helpers/google/gemini.d.ts +1 -1
- package/dist/api/helpers/google/gemini.js +43 -45
- package/dist/api/helpers/google/index.d.ts +2 -2
- package/dist/api/helpers/index.d.ts +17 -17
- package/dist/api/helpers/retryOnError.js +6 -11
- package/dist/api/helpers/s3.d.ts +9 -9
- package/dist/api/helpers/s3.js +19 -16
- package/dist/api/helpers/ses.d.ts +1 -1
- package/dist/api/helpers/ses.js +9 -9
- package/dist/api/helpers/sqs.d.ts +1 -1
- package/dist/api/helpers/sqs.js +1 -1
- package/dist/api/helpers/ssm.d.ts +1 -1
- package/dist/api/helpers/ssm.js +2 -2
- package/dist/api/helpers/ssmInfra/apigw.d.ts +6 -6
- package/dist/api/helpers/ssmInfra/apigw.js +6 -10
- package/dist/api/helpers/ssmInfra/dynamo.d.ts +2 -2
- package/dist/api/helpers/ssmInfra/dynamo.js +1 -1
- package/dist/api/helpers/ssmInfra/index.d.ts +4 -4
- package/dist/api/helpers/ssmInfra/s3.d.ts +3 -3
- package/dist/api/helpers/ssmInfra/s3.js +1 -1
- package/dist/api/helpers/ssmInfra/sqs.d.ts +3 -3
- package/dist/api/helpers/ssmInfra/sqs.js +1 -1
- package/dist/api/helpers/sts.d.ts +1 -1
- package/dist/api/helpers/sts.js +4 -4
- package/dist/api/helpers/validations.d.ts +2 -2
- package/dist/api/helpers/validations.js +14 -14
- package/dist/api/helpers/zod.d.ts +1 -1
- package/dist/api/helpers/zod.js +21 -27
- package/dist/api/index.d.ts +2 -2
- package/dist/api/types/aws.d.ts +0 -56
- package/dist/api/types/aws.js +0 -1
- package/dist/api/types/index.d.ts +1 -1
- package/dist/common/helpers/array.js +9 -10
- package/dist/common/helpers/async.js +2 -2
- package/dist/common/helpers/binary.d.ts +1 -1
- package/dist/common/helpers/binary.js +1 -1
- package/dist/common/helpers/csv.d.ts +4 -2
- package/dist/common/helpers/csv.js +8 -12
- package/dist/common/helpers/date.d.ts +2 -4
- package/dist/common/helpers/date.js +2 -2
- package/dist/common/helpers/email.js +2 -2
- package/dist/common/helpers/fetch.js +8 -8
- package/dist/common/helpers/generator.js +2 -2
- package/dist/common/helpers/groupBy.js +0 -2
- package/dist/common/helpers/hashCode.js +2 -6
- package/dist/common/helpers/headers.d.ts +20 -20
- package/dist/common/helpers/headers.js +38 -38
- package/dist/common/helpers/i18n.d.ts +2 -2
- package/dist/common/helpers/i18n.js +5 -6
- package/dist/common/helpers/index.d.ts +25 -25
- package/dist/common/helpers/log.d.ts +1 -1
- package/dist/common/helpers/log.js +30 -30
- package/dist/common/helpers/math.d.ts +2 -2
- package/dist/common/helpers/math.js +6 -6
- package/dist/common/helpers/memo.d.ts +1 -1
- package/dist/common/helpers/memo.js +1 -3
- package/dist/common/helpers/node-cache.d.ts +2 -2
- package/dist/common/helpers/node-cache.js +0 -1
- package/dist/common/helpers/object.d.ts +1 -1
- package/dist/common/helpers/object.js +16 -27
- package/dist/common/helpers/secondsInNearest.js +5 -5
- package/dist/common/helpers/stream.js +4 -6
- package/dist/common/helpers/string/base64.js +2 -2
- package/dist/common/helpers/string/chunk.js +1 -1
- package/dist/common/helpers/string/contains.js +1 -3
- package/dist/common/helpers/string/getExtendedStringSegment.js +1 -1
- package/dist/common/helpers/string/index.d.ts +11 -11
- package/dist/common/helpers/string/json.js +1 -1
- package/dist/common/helpers/string/redact.js +38 -39
- package/dist/common/helpers/string/trim.js +4 -4
- package/dist/common/helpers/string/truncate.js +1 -1
- package/dist/common/helpers/string/url.js +7 -8
- package/dist/common/helpers/withRetry.js +7 -7
- package/dist/common/helpers/xml.d.ts +7 -3
- package/dist/common/helpers/xml.js +33 -36
- package/dist/common/index.d.ts +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/node/helpers/fetch.js +1 -2
- package/dist/node/helpers/fs.js +2 -2
- package/dist/node/helpers/index.d.ts +2 -2
- package/dist/node/index.d.ts +1 -1
- package/dist/ui/components/DarkMode/Base.d.ts +4 -4
- package/dist/ui/components/DarkMode/Base.js +26 -31
- package/dist/ui/components/DarkMode/index.d.ts +2 -2
- package/dist/ui/components/DarkMode/types.d.ts +5 -5
- package/dist/ui/components/HeadersRaw/index.d.ts +2 -2
- package/dist/ui/components/HeadersRaw/index.js +5 -5
- package/dist/ui/components/Markdown/index.d.ts +1 -1
- package/dist/ui/components/Markdown/index.js +10 -10
- package/dist/ui/components/index.d.ts +4 -4
- package/dist/ui/components/shadcn/accordion.d.ts +4 -4
- package/dist/ui/components/shadcn/accordion.js +6 -6
- package/dist/ui/components/shadcn/alert.d.ts +2 -2
- package/dist/ui/components/shadcn/alert.js +6 -6
- package/dist/ui/components/shadcn/avatar.d.ts +2 -2
- package/dist/ui/components/shadcn/avatar.js +4 -4
- package/dist/ui/components/shadcn/button.d.ts +4 -4
- package/dist/ui/components/shadcn/button.js +14 -14
- package/dist/ui/components/shadcn/card.d.ts +2 -2
- package/dist/ui/components/shadcn/card.js +6 -6
- package/dist/ui/components/shadcn/checkbox.d.ts +2 -2
- package/dist/ui/components/shadcn/checkbox.js +3 -3
- package/dist/ui/components/shadcn/dialog.d.ts +10 -10
- package/dist/ui/components/shadcn/dialog.js +9 -11
- package/dist/ui/components/shadcn/divider.d.ts +1 -1
- package/dist/ui/components/shadcn/divider.js +1 -1
- package/dist/ui/components/shadcn/dropdown-list.d.ts +1 -1
- package/dist/ui/components/shadcn/dropdown-list.js +5 -5
- package/dist/ui/components/shadcn/dropdown-menu.d.ts +6 -6
- package/dist/ui/components/shadcn/dropdown-menu.js +11 -11
- package/dist/ui/components/shadcn/index.d.ts +21 -21
- package/dist/ui/components/shadcn/input-selector.d.ts +1 -1
- package/dist/ui/components/shadcn/input-selector.js +10 -12
- package/dist/ui/components/shadcn/input.d.ts +1 -1
- package/dist/ui/components/shadcn/input.js +1 -1
- package/dist/ui/components/shadcn/label.d.ts +3 -3
- package/dist/ui/components/shadcn/label.js +2 -2
- package/dist/ui/components/shadcn/popover.d.ts +2 -2
- package/dist/ui/components/shadcn/popover.js +3 -3
- package/dist/ui/components/shadcn/radio-group.d.ts +2 -2
- package/dist/ui/components/shadcn/radio-group.js +2 -2
- package/dist/ui/components/shadcn/scroll-area.d.ts +2 -2
- package/dist/ui/components/shadcn/scroll-area.js +3 -5
- package/dist/ui/components/shadcn/select.d.ts +2 -2
- package/dist/ui/components/shadcn/select.js +12 -12
- package/dist/ui/components/shadcn/sheet.d.ts +12 -12
- package/dist/ui/components/shadcn/sheet.js +15 -15
- package/dist/ui/components/shadcn/switch.d.ts +2 -2
- package/dist/ui/components/shadcn/switch.js +3 -3
- package/dist/ui/components/shadcn/textarea.d.ts +1 -1
- package/dist/ui/components/shadcn/textarea.js +1 -1
- package/dist/ui/components/shadcn/toast.d.ts +2 -2
- package/dist/ui/components/shadcn/toast.js +25 -25
- package/dist/ui/helpers/cognito.d.ts +1 -1
- package/dist/ui/helpers/cookie/const.js +1 -1
- package/dist/ui/helpers/cookie/get.js +3 -4
- package/dist/ui/helpers/cookie/index.d.ts +5 -5
- package/dist/ui/helpers/cookie/raw.d.ts +1 -1
- package/dist/ui/helpers/cookie/raw.js +8 -9
- package/dist/ui/helpers/cookie/use.d.ts +1 -1
- package/dist/ui/helpers/cookie/use.js +4 -4
- package/dist/ui/helpers/date.js +8 -8
- package/dist/ui/helpers/debounce.js +1 -1
- package/dist/ui/helpers/dom.d.ts +1 -1
- package/dist/ui/helpers/dom.js +4 -14
- package/dist/ui/helpers/index.d.ts +26 -26
- package/dist/ui/helpers/jwt.d.ts +3 -3
- package/dist/ui/helpers/openDialog.d.ts +2 -2
- package/dist/ui/helpers/openDialog.js +8 -8
- package/dist/ui/helpers/plural.js +1 -1
- package/dist/ui/helpers/routes.d.ts +2 -2
- package/dist/ui/helpers/routes.js +14 -15
- package/dist/ui/helpers/serviceWorker.js +1 -1
- package/dist/ui/helpers/useContextMenu.d.ts +1 -1
- package/dist/ui/helpers/useContextMenu.js +9 -10
- package/dist/ui/helpers/useElementAttribute.js +3 -5
- package/dist/ui/helpers/useGranularHook.d.ts +1 -1
- package/dist/ui/helpers/useGranularHook.js +2 -3
- package/dist/ui/helpers/useInterval.d.ts +2 -2
- package/dist/ui/helpers/useInterval.js +2 -2
- package/dist/ui/helpers/useIsInViewport.d.ts +1 -1
- package/dist/ui/helpers/useIsInViewport.js +0 -1
- package/dist/ui/helpers/useLocalStorage.js +6 -6
- package/dist/ui/helpers/useLockBodyScroll.js +2 -2
- package/dist/ui/helpers/useOnClickOutside.d.ts +1 -1
- package/dist/ui/helpers/useOnClickOutside.js +3 -6
- package/dist/ui/helpers/useOnScroll.d.ts +1 -1
- package/dist/ui/helpers/useOnScroll.js +3 -4
- package/dist/ui/helpers/useOverloadPageSearch.js +8 -10
- package/dist/ui/helpers/useQueryString.js +7 -7
- package/dist/ui/helpers/useResize.js +5 -6
- package/dist/ui/helpers/useTimeout.js +1 -1
- package/dist/ui/helpers/useTooltip.d.ts +2 -2
- package/dist/ui/helpers/useTooltip.js +5 -7
- package/dist/ui/helpers/utils.d.ts +2 -2
- package/dist/ui/icons/Checkmark.d.ts +2 -2
- package/dist/ui/icons/Checkmark.js +1 -1
- package/dist/ui/icons/ChevronRight.d.ts +1 -1
- package/dist/ui/icons/Circle.d.ts +2 -2
- package/dist/ui/icons/Circle.js +1 -1
- package/dist/ui/icons/CircleDot.d.ts +2 -2
- package/dist/ui/icons/Cog.d.ts +2 -2
- package/dist/ui/icons/Computer.d.ts +2 -2
- package/dist/ui/icons/Door.d.ts +1 -1
- package/dist/ui/icons/Hamburger.d.ts +1 -1
- package/dist/ui/icons/HorizontalDots.d.ts +1 -1
- package/dist/ui/icons/House.d.ts +2 -2
- package/dist/ui/icons/Magnify.d.ts +2 -2
- package/dist/ui/icons/Magnify.js +1 -1
- package/dist/ui/icons/Moon.d.ts +2 -2
- package/dist/ui/icons/Pencil.d.ts +1 -1
- package/dist/ui/icons/Save.d.ts +1 -1
- package/dist/ui/icons/Sun.d.ts +1 -1
- package/dist/ui/icons/Sun.js +1 -1
- package/dist/ui/icons/Undo.d.ts +1 -1
- package/dist/ui/icons/UserOutline.d.ts +1 -1
- package/dist/ui/icons/Warning.d.ts +2 -2
- package/dist/ui/icons/Warning.js +1 -1
- package/dist/ui/icons/index.d.ts +32 -74
- package/dist/ui/index.d.ts +3 -3
- package/dist/ui/styles/colours.js +29 -29
- package/dist/ui/styles/common.d.ts +1 -1
- package/dist/ui/styles/common.js +10 -10
- package/dist/ui/styles/index.d.ts +3 -3
- package/package.json +65 -75
package/dist/api/helpers/zod.js
CHANGED
|
@@ -30,75 +30,69 @@ function zodSchemaToString(schema) {
|
|
|
30
30
|
throw new Error(`Failed to convert field "${key}": ${e.message}`);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
return `z.object({\n${fields.join(
|
|
33
|
+
return `z.object({\n${fields.join(",\n")}\n})`;
|
|
34
34
|
}
|
|
35
35
|
/** Get the Zod 4 type name from _def.type (e.g. 'string', 'number', 'optional') */
|
|
36
36
|
function getTypeName(zodType) {
|
|
37
37
|
const type = zodType._def.type;
|
|
38
|
-
return typeof type ===
|
|
38
|
+
return typeof type === "string" ? type : undefined;
|
|
39
39
|
}
|
|
40
40
|
/** Recursively convert a Zod type to its code representation. */
|
|
41
41
|
function zodTypeToCode(zodType) {
|
|
42
42
|
const description = zodType.description;
|
|
43
|
-
const describeChain = description
|
|
44
|
-
? `.describe(${JSON.stringify(description)})`
|
|
45
|
-
: '';
|
|
43
|
+
const describeChain = description ? `.describe(${JSON.stringify(description)})` : "";
|
|
46
44
|
const def = zodType._def;
|
|
47
45
|
const typeName = getTypeName(zodType);
|
|
48
46
|
// Wrapper types (unwrap inner type)
|
|
49
|
-
if (typeName ===
|
|
50
|
-
const inner = zodTypeToCode(def.innerType).replace(/\.describe\([^)]+\)$/,
|
|
47
|
+
if (typeName === "optional") {
|
|
48
|
+
const inner = zodTypeToCode(def.innerType).replace(/\.describe\([^)]+\)$/, "");
|
|
51
49
|
return `${inner}.optional()${describeChain}`;
|
|
52
50
|
}
|
|
53
|
-
if (typeName ===
|
|
54
|
-
const inner = zodTypeToCode(def.innerType).replace(/\.describe\([^)]+\)$/,
|
|
51
|
+
if (typeName === "nullable") {
|
|
52
|
+
const inner = zodTypeToCode(def.innerType).replace(/\.describe\([^)]+\)$/, "");
|
|
55
53
|
return `${inner}.nullable()${describeChain}`;
|
|
56
54
|
}
|
|
57
55
|
// Primitives
|
|
58
|
-
if (typeName ===
|
|
56
|
+
if (typeName === "string")
|
|
59
57
|
return `z.string()${describeChain}`;
|
|
60
|
-
if (typeName ===
|
|
58
|
+
if (typeName === "number")
|
|
61
59
|
return `z.number()${describeChain}`;
|
|
62
|
-
if (typeName ===
|
|
60
|
+
if (typeName === "boolean")
|
|
63
61
|
return `z.boolean()${describeChain}`;
|
|
64
62
|
// Enum: _def.entries is { [k]: k }
|
|
65
|
-
if (typeName ===
|
|
63
|
+
if (typeName === "enum") {
|
|
66
64
|
const values = Object.keys(def.entries);
|
|
67
|
-
const enumStr = values.map((v) => JSON.stringify(v)).join(
|
|
65
|
+
const enumStr = values.map((v) => JSON.stringify(v)).join(", ");
|
|
68
66
|
return `z.enum([${enumStr}])${describeChain}`;
|
|
69
67
|
}
|
|
70
68
|
// Array: _def.element is the element type
|
|
71
|
-
if (typeName ===
|
|
69
|
+
if (typeName === "array") {
|
|
72
70
|
const inner = zodTypeToCode(def.element);
|
|
73
71
|
return `z.array(${inner})${describeChain}`;
|
|
74
72
|
}
|
|
75
73
|
// Object: recurse into shape
|
|
76
|
-
if (typeName ===
|
|
74
|
+
if (typeName === "object") {
|
|
77
75
|
return zodSchemaToString(zodType);
|
|
78
76
|
}
|
|
79
77
|
// Literal: _def.values is an array (e.g. ['foo'])
|
|
80
|
-
if (typeName ===
|
|
78
|
+
if (typeName === "literal") {
|
|
81
79
|
const value = def.values[0];
|
|
82
80
|
return `z.literal(${JSON.stringify(value)})${describeChain}`;
|
|
83
81
|
}
|
|
84
82
|
// Union: _def.options is array of Zod types
|
|
85
|
-
if (typeName ===
|
|
86
|
-
const optionsStr = def.options
|
|
87
|
-
.map((opt) => zodTypeToCode(opt))
|
|
88
|
-
.join(', ');
|
|
83
|
+
if (typeName === "union") {
|
|
84
|
+
const optionsStr = def.options.map((opt) => zodTypeToCode(opt)).join(", ");
|
|
89
85
|
return `z.union([${optionsStr}])${describeChain}`;
|
|
90
86
|
}
|
|
91
87
|
// Record: _def.keyType + _def.valueType (valueType may be undefined for single-arg z.record(keyType))
|
|
92
|
-
if (typeName ===
|
|
88
|
+
if (typeName === "record") {
|
|
93
89
|
const innerType = (def.valueType ?? def.keyType);
|
|
94
90
|
return `z.record(${zodTypeToCode(innerType)})${describeChain}`;
|
|
95
91
|
}
|
|
96
92
|
// Tuple: _def.items is array of Zod types
|
|
97
|
-
if (typeName ===
|
|
98
|
-
const itemsStr = def.items
|
|
99
|
-
.map((item) => zodTypeToCode(item))
|
|
100
|
-
.join(', ');
|
|
93
|
+
if (typeName === "tuple") {
|
|
94
|
+
const itemsStr = def.items.map((item) => zodTypeToCode(item)).join(", ");
|
|
101
95
|
return `z.tuple([${itemsStr}])${describeChain}`;
|
|
102
96
|
}
|
|
103
|
-
throw new Error(`Unsupported Zod type: ${typeName} (keys: ${Object.keys(def).join(
|
|
97
|
+
throw new Error(`Unsupported Zod type: ${typeName} (keys: ${Object.keys(def).join(", ")})`);
|
|
104
98
|
}
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export type * from
|
|
1
|
+
export * from "./helpers";
|
|
2
|
+
export type * from "./types/index";
|
package/dist/api/types/aws.d.ts
CHANGED
|
@@ -30,59 +30,3 @@ export interface APIGatewayEvent {
|
|
|
30
30
|
httpMethod: string;
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
export interface AppSyncResolverEvent<TArguments, TSource = Record<string, any> | null> {
|
|
34
|
-
arguments: TArguments;
|
|
35
|
-
identity?: any;
|
|
36
|
-
source: TSource;
|
|
37
|
-
request: {
|
|
38
|
-
headers: {
|
|
39
|
-
[name: string]: string | undefined;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
info: {
|
|
43
|
-
selectionSetList: string[];
|
|
44
|
-
selectionSetGraphQL: string;
|
|
45
|
-
parentTypeName: string;
|
|
46
|
-
fieldName: string;
|
|
47
|
-
variables: {
|
|
48
|
-
[key: string]: any;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
prev: {
|
|
52
|
-
result: {
|
|
53
|
-
[key: string]: any;
|
|
54
|
-
};
|
|
55
|
-
} | null;
|
|
56
|
-
stash: {
|
|
57
|
-
[key: string]: any;
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
export interface DynamoDBStreamEvent {
|
|
61
|
-
Records: {
|
|
62
|
-
awsRegion?: string | undefined;
|
|
63
|
-
dynamodb?: {
|
|
64
|
-
ApproximateCreationDateTime?: number | undefined;
|
|
65
|
-
Keys?: {
|
|
66
|
-
[key: string]: any;
|
|
67
|
-
} | undefined;
|
|
68
|
-
NewImage?: {
|
|
69
|
-
[key: string]: any;
|
|
70
|
-
} | undefined;
|
|
71
|
-
OldImage?: {
|
|
72
|
-
[key: string]: any;
|
|
73
|
-
} | undefined;
|
|
74
|
-
SequenceNumber?: string | undefined;
|
|
75
|
-
SizeBytes?: number | undefined;
|
|
76
|
-
StreamViewType?: 'KEYS_ONLY' | 'NEW_IMAGE' | 'OLD_IMAGE' | 'NEW_AND_OLD_IMAGES' | undefined;
|
|
77
|
-
} | undefined;
|
|
78
|
-
eventID?: string | undefined;
|
|
79
|
-
eventName?: 'INSERT' | 'MODIFY' | 'REMOVE' | undefined;
|
|
80
|
-
eventSource?: string | undefined;
|
|
81
|
-
eventSourceARN?: string | undefined;
|
|
82
|
-
eventVersion?: string | undefined;
|
|
83
|
-
userIdentity?: any;
|
|
84
|
-
}[];
|
|
85
|
-
}
|
|
86
|
-
export type Key = {
|
|
87
|
-
[key: string]: any;
|
|
88
|
-
};
|
package/dist/api/types/aws.js
CHANGED
|
@@ -17,7 +17,6 @@ keyF,
|
|
|
17
17
|
*/
|
|
18
18
|
valueF) => {
|
|
19
19
|
const ret = {};
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
21
20
|
if (!arr || !keyF) {
|
|
22
21
|
return ret;
|
|
23
22
|
}
|
|
@@ -57,12 +56,10 @@ const chunk = (array, max) => {
|
|
|
57
56
|
return rows;
|
|
58
57
|
};
|
|
59
58
|
exports.chunk = chunk;
|
|
60
|
-
const partition = (array, func) => !array.length
|
|
61
|
-
? null
|
|
62
|
-
: [array.filter((r) => func(r)), array.filter((r) => !func(r))];
|
|
59
|
+
const partition = (array, func) => !array.length ? null : [array.filter((r) => func(r)), array.filter((r) => !func(r))];
|
|
63
60
|
exports.partition = partition;
|
|
64
61
|
/** removes null, undefined, false, empty string */
|
|
65
|
-
const notEmpty = (value) => value !== null && value !== undefined && value !== false && value !==
|
|
62
|
+
const notEmpty = (value) => value !== null && value !== undefined && value !== false && value !== "";
|
|
66
63
|
exports.notEmpty = notEmpty;
|
|
67
64
|
/**
|
|
68
65
|
* return a distinct array of items determined by a key function
|
|
@@ -77,7 +74,7 @@ function distinctBy(data, key, ignoreEmpty) {
|
|
|
77
74
|
const hashSet = new Set();
|
|
78
75
|
return data.filter((x) => {
|
|
79
76
|
let keyVal;
|
|
80
|
-
if (typeof key ===
|
|
77
|
+
if (typeof key === "string") {
|
|
81
78
|
keyVal = x[key];
|
|
82
79
|
}
|
|
83
80
|
else {
|
|
@@ -93,9 +90,7 @@ function distinctBy(data, key, ignoreEmpty) {
|
|
|
93
90
|
return false;
|
|
94
91
|
});
|
|
95
92
|
}
|
|
96
|
-
const distinct = (arr) => [
|
|
97
|
-
...new Set(arr),
|
|
98
|
-
];
|
|
93
|
+
const distinct = (arr) => [...new Set(arr)];
|
|
99
94
|
exports.distinct = distinct;
|
|
100
95
|
function findLastIndex(arr, predicate) {
|
|
101
96
|
for (let i = arr.length - 1; i >= 0; i--) {
|
|
@@ -105,5 +100,9 @@ function findLastIndex(arr, predicate) {
|
|
|
105
100
|
}
|
|
106
101
|
return -1;
|
|
107
102
|
}
|
|
108
|
-
const insertElementAtIndex = (arr, element, index) => [
|
|
103
|
+
const insertElementAtIndex = (arr, element, index) => [
|
|
104
|
+
...arr.slice(0, index),
|
|
105
|
+
element,
|
|
106
|
+
...arr.slice(index),
|
|
107
|
+
];
|
|
109
108
|
exports.insertElementAtIndex = insertElementAtIndex;
|
|
@@ -17,7 +17,7 @@ async function asyncForEach(array, callback, opt) {
|
|
|
17
17
|
rem = rest;
|
|
18
18
|
const proms = part.map((p, i) => callback(p, start + i, array));
|
|
19
19
|
start += part.length;
|
|
20
|
-
//
|
|
20
|
+
// oxlint-disable-next-line no-await-in-loop -- concurrency is intentionally bounded per batch
|
|
21
21
|
await Promise.all(proms);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -37,7 +37,7 @@ async function asyncMap(array, callback, opt) {
|
|
|
37
37
|
rem = rest;
|
|
38
38
|
const proms = part.map((p, i) => callback(p, start + i, array));
|
|
39
39
|
start += part.length;
|
|
40
|
-
//
|
|
40
|
+
// oxlint-disable-next-line no-await-in-loop -- concurrency is intentionally bounded per batch
|
|
41
41
|
const res = await Promise.all(proms);
|
|
42
42
|
ret.push(...res);
|
|
43
43
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Buffer } from
|
|
1
|
+
import { Buffer } from "buffer";
|
|
2
2
|
export declare const toBuffer: (ab: ArrayBuffer) => Buffer<ArrayBuffer>;
|
|
3
3
|
export declare function bufferToArrayBuffer(buffer: Buffer): ArrayBuffer;
|
|
4
4
|
export declare function b64ToArrayBuffer(base64: string): ArrayBuffer;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
type CsvValue = number | string;
|
|
2
|
+
export declare function loadCsvAsJson<T extends Record<string, CsvValue>>(p: {
|
|
2
3
|
fileData: string;
|
|
3
4
|
opt?: {
|
|
4
5
|
typeOverrides?: {
|
|
5
6
|
headerName: string;
|
|
6
|
-
type:
|
|
7
|
+
type: "string" | "number";
|
|
7
8
|
}[];
|
|
8
9
|
};
|
|
9
10
|
}): T[];
|
|
11
|
+
export {};
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadCsvAsJson = loadCsvAsJson;
|
|
4
4
|
const math_1 = require("./math");
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
5
|
function loadCsvAsJson(p) {
|
|
7
6
|
const lines = p.fileData.split(/[\r]?\n/);
|
|
8
|
-
let sep =
|
|
9
|
-
if (lines[0].split(
|
|
10
|
-
sep =
|
|
7
|
+
let sep = ",";
|
|
8
|
+
if (lines[0].split(",").length === 1 && lines[0].split(";").length > 1) {
|
|
9
|
+
sep = ";";
|
|
11
10
|
}
|
|
12
11
|
const headers = lines[0]
|
|
13
12
|
.split(sep)
|
|
@@ -15,14 +14,14 @@ function loadCsvAsJson(p) {
|
|
|
15
14
|
const jsonData = lines.slice(1).map((line) => {
|
|
16
15
|
const values = [];
|
|
17
16
|
let inQuote = false;
|
|
18
|
-
let currentValue =
|
|
17
|
+
let currentValue = "";
|
|
19
18
|
for (const char of line) {
|
|
20
19
|
if (char === '"') {
|
|
21
20
|
inQuote = !inQuote;
|
|
22
21
|
}
|
|
23
22
|
else if (char === sep && !inQuote) {
|
|
24
23
|
values.push(currentValue.trim());
|
|
25
|
-
currentValue =
|
|
24
|
+
currentValue = "";
|
|
26
25
|
}
|
|
27
26
|
else {
|
|
28
27
|
currentValue += char;
|
|
@@ -32,19 +31,16 @@ function loadCsvAsJson(p) {
|
|
|
32
31
|
const obj = {};
|
|
33
32
|
for (let i = 0; i < headers.length; i++) {
|
|
34
33
|
const v = values[i];
|
|
35
|
-
if (v ===
|
|
34
|
+
if (v === "-") {
|
|
36
35
|
//ignore
|
|
37
36
|
}
|
|
38
|
-
else if (headers[i][1] ===
|
|
39
|
-
//@ts-ignore
|
|
37
|
+
else if (headers[i][1] === "string") {
|
|
40
38
|
obj[headers[i][0]] = v.toString();
|
|
41
39
|
}
|
|
42
|
-
else if (headers[i][1] ===
|
|
43
|
-
//@ts-ignore
|
|
40
|
+
else if (headers[i][1] === "number" || (0, math_1.isNumber)(v)) {
|
|
44
41
|
obj[headers[i][0]] = Number(v);
|
|
45
42
|
}
|
|
46
43
|
else {
|
|
47
|
-
//@ts-ignore
|
|
48
44
|
obj[headers[i][0]] = v;
|
|
49
45
|
}
|
|
50
46
|
}
|
|
@@ -37,9 +37,7 @@ export interface IUtcDateParams {
|
|
|
37
37
|
minutes: number;
|
|
38
38
|
seconds: number;
|
|
39
39
|
}
|
|
40
|
-
export declare const getUtcDateTime: (
|
|
41
|
-
/** if true will 0 H,M,S */
|
|
42
|
-
skipTime?: boolean) => {
|
|
40
|
+
export declare const getUtcDateTime: (skipTime?: boolean) => {
|
|
43
41
|
ticks: number;
|
|
44
42
|
};
|
|
45
|
-
export declare const toMs: ({ day, hours, minutes, month, seconds, year
|
|
43
|
+
export declare const toMs: ({ day, hours, minutes, month, seconds, year }: IUtcDateParams) => number;
|
|
@@ -72,7 +72,7 @@ skipTime) => {
|
|
|
72
72
|
hours: date.getUTCHours(),
|
|
73
73
|
minutes: date.getUTCMinutes(),
|
|
74
74
|
seconds: date.getUTCSeconds(),
|
|
75
|
-
tz:
|
|
75
|
+
tz: "UTC",
|
|
76
76
|
};
|
|
77
77
|
if (skipTime) {
|
|
78
78
|
p.hours = p.minutes = p.seconds = 0;
|
|
@@ -81,7 +81,7 @@ skipTime) => {
|
|
|
81
81
|
return { ticks };
|
|
82
82
|
};
|
|
83
83
|
exports.getUtcDateTime = getUtcDateTime;
|
|
84
|
-
const toMs = ({ day, hours, minutes, month, seconds, year
|
|
84
|
+
const toMs = ({ day, hours, minutes, month, seconds, year }) => {
|
|
85
85
|
// Calculate milliseconds in a year (365 days x 24 hours x 60 minutes x 60 seconds x 1000 milliseconds)
|
|
86
86
|
const millisecondsInYear = 365 * 24 * 60 * 60 * 1000;
|
|
87
87
|
// Calculate milliseconds in a month (based on 30 days)
|
|
@@ -11,10 +11,10 @@ const isEmailValid = (email) => {
|
|
|
11
11
|
const valid = regex.test(email);
|
|
12
12
|
if (!valid)
|
|
13
13
|
return false;
|
|
14
|
-
const parts = email.split(
|
|
14
|
+
const parts = email.split("@");
|
|
15
15
|
if (parts[0].length > 64)
|
|
16
16
|
return false;
|
|
17
|
-
const domainParts = parts[1].split(
|
|
17
|
+
const domainParts = parts[1].split(".");
|
|
18
18
|
if (domainParts.some((part) => part.length > 64)) {
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
@@ -13,10 +13,10 @@ async function fetchToMemory(imageUrl) {
|
|
|
13
13
|
if (!response.ok) {
|
|
14
14
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
15
15
|
}
|
|
16
|
-
let type = response.headers.get(
|
|
17
|
-
if (type.includes(
|
|
18
|
-
(0, log_1.debug)(
|
|
19
|
-
type =
|
|
16
|
+
let type = response.headers.get("content-type") || "image/jpeg";
|
|
17
|
+
if (type.includes("octet")) {
|
|
18
|
+
(0, log_1.debug)("forcing type to jpeg:" + imageUrl);
|
|
19
|
+
type = "image/jpeg";
|
|
20
20
|
}
|
|
21
21
|
// Get the image data as an ArrayBuffer
|
|
22
22
|
const arraybuffer = await response.arrayBuffer();
|
|
@@ -24,19 +24,19 @@ async function fetchToMemory(imageUrl) {
|
|
|
24
24
|
}
|
|
25
25
|
catch (e) {
|
|
26
26
|
const em = e;
|
|
27
|
-
(0, log_1.warn)(
|
|
27
|
+
(0, log_1.warn)("Error downloading image:", imageUrl, em.toString());
|
|
28
28
|
return undefined;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
const imageExistsCache = new node_cache_1.TypedNodeCache({ stdTTL: 60 * 60 * 24 });
|
|
32
32
|
async function fetchExists(imageUrl) {
|
|
33
33
|
const cached = imageExistsCache.get(imageUrl);
|
|
34
|
-
if (typeof cached ===
|
|
34
|
+
if (typeof cached === "boolean") {
|
|
35
35
|
return cached;
|
|
36
36
|
}
|
|
37
37
|
const response = await (0, withRetry_1.withRetry)(async () => {
|
|
38
38
|
const response = await fetch(imageUrl, {
|
|
39
|
-
method:
|
|
39
|
+
method: "HEAD",
|
|
40
40
|
headers: (0, headers_1.getFetchHeaders)(),
|
|
41
41
|
});
|
|
42
42
|
if (response.status === 200)
|
|
@@ -44,7 +44,7 @@ async function fetchExists(imageUrl) {
|
|
|
44
44
|
if (response.status === 404)
|
|
45
45
|
return false;
|
|
46
46
|
throw new Error(`Unexpected status: ${response.status}`);
|
|
47
|
-
},
|
|
47
|
+
}, "imageExistsAtUrl");
|
|
48
48
|
if (response === false) {
|
|
49
49
|
imageExistsCache.set(imageUrl, false, 1);
|
|
50
50
|
}
|
|
@@ -4,12 +4,12 @@ exports.runGenerator = runGenerator;
|
|
|
4
4
|
async function runGenerator(iter, partialRun) {
|
|
5
5
|
let curr;
|
|
6
6
|
do {
|
|
7
|
-
//
|
|
7
|
+
// oxlint-disable-next-line no-await-in-loop -- generator batches must be consumed in order
|
|
8
8
|
curr = await iter.next();
|
|
9
9
|
if (curr.value.length === 0) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
//
|
|
12
|
+
// oxlint-disable-next-line no-await-in-loop -- each batch must finish before advancing
|
|
13
13
|
await partialRun(curr.value);
|
|
14
14
|
} while (!curr.done);
|
|
15
15
|
}
|
|
@@ -12,7 +12,6 @@ function groupBy(arr, getKey) {
|
|
|
12
12
|
const ret = {};
|
|
13
13
|
arr.forEach((item) => {
|
|
14
14
|
const key = getKey(item);
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
16
15
|
if (!ret[key]) {
|
|
17
16
|
ret[key] = [];
|
|
18
17
|
}
|
|
@@ -44,7 +43,6 @@ function groupByTwice(arr, getKey, getSubKey) {
|
|
|
44
43
|
arr.forEach((item) => {
|
|
45
44
|
const key = getKey(item);
|
|
46
45
|
const subkey = getSubKey(item);
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
48
46
|
if (!ret[key]) {
|
|
49
47
|
ret[key] = {};
|
|
50
48
|
}
|
|
@@ -15,12 +15,8 @@ const hashCodeInt = (str, seed = 0) => {
|
|
|
15
15
|
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
16
16
|
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
17
17
|
}
|
|
18
|
-
h1 =
|
|
19
|
-
|
|
20
|
-
Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
21
|
-
h2 =
|
|
22
|
-
Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^
|
|
23
|
-
Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
18
|
+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
19
|
+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
24
20
|
const ret = 4294967296 * (2097151 & h2) + (h1 >>> 0);
|
|
25
21
|
return ret;
|
|
26
22
|
};
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
export declare const getFetchHeaders: (host?: string) => {
|
|
2
2
|
accept: string;
|
|
3
|
-
|
|
3
|
+
"accept-language": string;
|
|
4
4
|
connection: string;
|
|
5
5
|
dnt: string;
|
|
6
6
|
host: string;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
"sec-fetch-dest": string;
|
|
8
|
+
"sec-fetch-mode": string;
|
|
9
|
+
"sec-fetch-site": string;
|
|
10
|
+
"user-agent": string;
|
|
11
|
+
"sec-ch-ua": string;
|
|
12
|
+
"sec-ch-ua-mobile": string;
|
|
13
|
+
"sec-ch-ua-platform": string;
|
|
14
|
+
"sec-fetch-user": string;
|
|
15
|
+
"upgrade-insecure-requests": string;
|
|
16
|
+
"viewport-width": string;
|
|
17
|
+
"viewport-height": string;
|
|
18
|
+
"sec-ch-ua-full-version-list": string;
|
|
19
|
+
"sec-ch-ua-arch": string;
|
|
20
|
+
"sec-ch-ua-bitness": string;
|
|
21
|
+
"sec-ch-ua-model": string;
|
|
22
|
+
"sec-ch-ua-platform-version": string;
|
|
23
|
+
"sec-ch-ua-wow64": string;
|
|
24
|
+
"device-memory": string;
|
|
25
25
|
downlink: string;
|
|
26
26
|
ect: string;
|
|
27
27
|
rtt: string;
|
|
28
|
-
|
|
28
|
+
"color-depth": string;
|
|
29
29
|
};
|
|
@@ -2,26 +2,26 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFetchHeaders = void 0;
|
|
4
4
|
const languages = [
|
|
5
|
-
|
|
5
|
+
"en-AU,en;q=0.9,en-GB;q=0.8,en-US;q=0.7,cy;q=0.6,af;q=0.5,lb;q=0.4,hu;q=0.3,pt;q=0.2",
|
|
6
6
|
];
|
|
7
7
|
const browsers = [
|
|
8
8
|
{
|
|
9
|
-
name:
|
|
10
|
-
version:
|
|
11
|
-
userAgent:
|
|
9
|
+
name: "Google Chrome",
|
|
10
|
+
version: "135",
|
|
11
|
+
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36",
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
|
-
name:
|
|
15
|
-
version:
|
|
16
|
-
userAgent:
|
|
14
|
+
name: "Firefox",
|
|
15
|
+
version: "124",
|
|
16
|
+
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0",
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
|
-
name:
|
|
20
|
-
version:
|
|
21
|
-
userAgent:
|
|
19
|
+
name: "Edge",
|
|
20
|
+
version: "122",
|
|
21
|
+
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0",
|
|
22
22
|
},
|
|
23
23
|
];
|
|
24
|
-
const platforms = [
|
|
24
|
+
const platforms = ["Windows", "Macintosh", "Linux"];
|
|
25
25
|
const getRandomItem = (array) => {
|
|
26
26
|
return array[Math.floor(Math.random() * array.length)];
|
|
27
27
|
};
|
|
@@ -39,35 +39,35 @@ const getFetchHeaders = (host) => {
|
|
|
39
39
|
const viewport = getRandomItem(viewports);
|
|
40
40
|
const platform = getRandomItem(platforms);
|
|
41
41
|
const colorDepth = getRandomItem([24, 30, 48]);
|
|
42
|
-
const connection = getRandomItem([
|
|
42
|
+
const connection = getRandomItem(["4g", "5g", "wifi"]);
|
|
43
43
|
return {
|
|
44
|
-
accept:
|
|
45
|
-
|
|
46
|
-
connection:
|
|
47
|
-
dnt:
|
|
48
|
-
host: host ||
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
downlink: getRandomItem([
|
|
44
|
+
accept: "*/*",
|
|
45
|
+
"accept-language": getRandomItem(languages),
|
|
46
|
+
connection: "keep-alive",
|
|
47
|
+
dnt: "1",
|
|
48
|
+
host: host || "",
|
|
49
|
+
"sec-fetch-dest": "empty",
|
|
50
|
+
"sec-fetch-mode": "cors",
|
|
51
|
+
"sec-fetch-site": "same-origin",
|
|
52
|
+
"user-agent": browser.userAgent,
|
|
53
|
+
"sec-ch-ua": browserString,
|
|
54
|
+
"sec-ch-ua-mobile": "?0",
|
|
55
|
+
"sec-ch-ua-platform": '"Windows"',
|
|
56
|
+
"sec-fetch-user": "?1",
|
|
57
|
+
"upgrade-insecure-requests": "1",
|
|
58
|
+
"viewport-width": viewport.width.toString(),
|
|
59
|
+
"viewport-height": viewport.height.toString(),
|
|
60
|
+
"sec-ch-ua-full-version-list": browserString,
|
|
61
|
+
"sec-ch-ua-arch": `"${platform === "Windows" ? "x86" : "arm"}"`,
|
|
62
|
+
"sec-ch-ua-bitness": "64",
|
|
63
|
+
"sec-ch-ua-model": "",
|
|
64
|
+
"sec-ch-ua-platform-version": platform === "Windows" ? '"15.0.0"' : '"14.0.0"',
|
|
65
|
+
"sec-ch-ua-wow64": "?0",
|
|
66
|
+
"device-memory": getRandomItem(["4", "8", "16"]),
|
|
67
|
+
downlink: getRandomItem(["1.5", "5.0", "10.0"]),
|
|
68
68
|
ect: connection,
|
|
69
|
-
rtt: getRandomItem([
|
|
70
|
-
|
|
69
|
+
rtt: getRandomItem(["50", "100", "150"]),
|
|
70
|
+
"color-depth": colorDepth.toString(),
|
|
71
71
|
};
|
|
72
72
|
};
|
|
73
73
|
exports.getFetchHeaders = getFetchHeaders;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
type TLangExceptEn =
|
|
2
|
-
export type TLang = TLangExceptEn |
|
|
1
|
+
type TLangExceptEn = "id" | "vi" | "pt";
|
|
2
|
+
export type TLang = TLangExceptEn | "en";
|
|
3
3
|
export declare const AllLang: TLang[];
|
|
4
4
|
/**
|
|
5
5
|
* null = wont translate. undefined = fallback to eng
|