@xube/kit-aws-schema 0.0.47

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.
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,3 @@
1
+ export * from "./schema/fields";
2
+ export * from "./schema/item";
3
+ export * from "./schema/keys";
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./schema/fields"), exports);
18
+ __exportStar(require("./schema/item"), exports);
19
+ __exportStar(require("./schema/keys"), exports);
@@ -0,0 +1 @@
1
+ export declare const ID_FIELD = "id";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ID_FIELD = void 0;
4
+ exports.ID_FIELD = "id";
@@ -0,0 +1,40 @@
1
+ import { z } from "zod";
2
+ export declare const TableItemSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ type: z.ZodString;
5
+ s: z.ZodNumber;
6
+ us: z.ZodOptional<z.ZodNumber>;
7
+ PK: z.ZodString;
8
+ SK: z.ZodString;
9
+ }, "strip", z.ZodTypeAny, {
10
+ id: string;
11
+ PK: string;
12
+ SK: string;
13
+ type: string;
14
+ s: number;
15
+ us?: number | undefined;
16
+ }, {
17
+ id: string;
18
+ PK: string;
19
+ SK: string;
20
+ type: string;
21
+ s: number;
22
+ us?: number | undefined;
23
+ }>;
24
+ export type TableItem = z.infer<typeof TableItemSchema>;
25
+ export declare const isTableItem: (obj: unknown) => obj is {
26
+ id: string;
27
+ PK: string;
28
+ SK: string;
29
+ type: string;
30
+ s: number;
31
+ us?: number | undefined;
32
+ };
33
+ export declare const areTableItems: (obj: unknown) => obj is {
34
+ id: string;
35
+ PK: string;
36
+ SK: string;
37
+ type: string;
38
+ s: number;
39
+ us?: number | undefined;
40
+ }[];
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.areTableItems = exports.isTableItem = exports.TableItemSchema = void 0;
4
+ const kit_schema_1 = require("@xube/kit-schema");
5
+ const keys_1 = require("./keys");
6
+ const zod_1 = require("zod");
7
+ exports.TableItemSchema = kit_schema_1.BaseDataSchema.merge(keys_1.TableKeySchema);
8
+ const isTableItem = (obj) => exports.TableItemSchema.passthrough().safeParse(obj).success;
9
+ exports.isTableItem = isTableItem;
10
+ const areTableItems = (obj) => {
11
+ return zod_1.z.array(exports.TableItemSchema.passthrough()).safeParse(obj).success;
12
+ };
13
+ exports.areTableItems = areTableItems;
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ export declare const PARTITION_KEY = "PK";
3
+ export declare const SORT_KEY = "SK";
4
+ export declare const TableKeySchema: z.ZodObject<{
5
+ PK: z.ZodString;
6
+ SK: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ PK: string;
9
+ SK: string;
10
+ }, {
11
+ PK: string;
12
+ SK: string;
13
+ }>;
14
+ export type TableKey = z.infer<typeof TableKeySchema>;
15
+ export declare const PartialTableKey: z.ZodObject<{
16
+ PK: z.ZodString;
17
+ SK: z.ZodOptional<z.ZodString>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ PK: string;
20
+ SK?: string | undefined;
21
+ }, {
22
+ PK: string;
23
+ SK?: string | undefined;
24
+ }>;
25
+ export type PartialTableKey = z.infer<typeof PartialTableKey>;
26
+ export declare const getAggregateKeyFromTableKey: (tableKey: TableKey) => string;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAggregateKeyFromTableKey = exports.PartialTableKey = exports.TableKeySchema = exports.SORT_KEY = exports.PARTITION_KEY = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.PARTITION_KEY = "PK";
6
+ exports.SORT_KEY = "SK";
7
+ exports.TableKeySchema = zod_1.z.object({
8
+ [exports.PARTITION_KEY]: zod_1.z.string(),
9
+ [exports.SORT_KEY]: zod_1.z.string(),
10
+ });
11
+ exports.PartialTableKey = zod_1.z.object({
12
+ [exports.PARTITION_KEY]: zod_1.z.string(),
13
+ [exports.SORT_KEY]: zod_1.z.string().optional(),
14
+ });
15
+ const getAggregateKeyFromTableKey = (tableKey) => {
16
+ return `${tableKey[exports.PARTITION_KEY]}##${tableKey[exports.SORT_KEY]}`;
17
+ };
18
+ exports.getAggregateKeyFromTableKey = getAggregateKeyFromTableKey;
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@xube/kit-aws-schema",
3
+ "version": "0.0.47",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+ssh://git@github.com/XubeLtd/dev-kit.git"
12
+ },
13
+ "author": "Xube Pty Ltd",
14
+ "license": "MIT",
15
+ "bugs": {
16
+ "url": "https://github.com/XubeLtd/dev-kit/issues"
17
+ },
18
+ "homepage": "https://github.com/XubeLtd/dev-kit#readme",
19
+ "devDependencies": {
20
+ "@types/aws-lambda": "^8.10.119",
21
+ "@xube/kit-build": "^0.0.47"
22
+ },
23
+ "dependencies": {
24
+ "@xube/kit-schema": "^0.0.47",
25
+ "zod": "^3.22.4"
26
+ }
27
+ }
File without changes
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./schema/fields";
2
+ export * from "./schema/item";
3
+ export * from "./schema/keys";
@@ -0,0 +1 @@
1
+ export const ID_FIELD = "id"
@@ -0,0 +1,12 @@
1
+ import { BaseDataSchema } from "@xube/kit-schema";
2
+ import { TableKeySchema } from "./keys";
3
+ import { z } from "zod";
4
+
5
+ export const TableItemSchema = BaseDataSchema.merge(TableKeySchema);
6
+ export type TableItem = z.infer<typeof TableItemSchema>;
7
+ export const isTableItem = (obj: unknown): obj is TableItem =>
8
+ TableItemSchema.passthrough().safeParse(obj).success;
9
+
10
+ export const areTableItems = (obj: unknown): obj is TableItem[] => {
11
+ return z.array(TableItemSchema.passthrough()).safeParse(obj).success;
12
+ };
@@ -0,0 +1,20 @@
1
+ import { z } from "zod";
2
+
3
+ export const PARTITION_KEY = "PK";
4
+ export const SORT_KEY = "SK";
5
+
6
+ export const TableKeySchema = z.object({
7
+ [PARTITION_KEY]: z.string(),
8
+ [SORT_KEY]: z.string(),
9
+ });
10
+ export type TableKey = z.infer<typeof TableKeySchema>;
11
+
12
+ export const PartialTableKey = z.object({
13
+ [PARTITION_KEY]: z.string(),
14
+ [SORT_KEY]: z.string().optional(),
15
+ });
16
+ export type PartialTableKey = z.infer<typeof PartialTableKey>;
17
+
18
+ export const getAggregateKeyFromTableKey = (tableKey: TableKey) => {
19
+ return `${tableKey[PARTITION_KEY]}##${tableKey[SORT_KEY]}`;
20
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "extends": "../kit-build/tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "outDir": "./dist"
6
+ },
7
+ "exclude": ["**/*.test.ts", "**/*.mock.ts", "dist"],
8
+ "references": [
9
+ {
10
+ "path": "../kit-constants"
11
+ },
12
+ {
13
+ "path": "../kit-log"
14
+ },
15
+ {
16
+ "path": "../kit-schema"
17
+ }
18
+ ]
19
+ }