@deessejs/collections 0.0.2 → 0.0.4

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.
@@ -0,0 +1,2 @@
1
+ import { Collection } from "./types";
2
+ export declare const collection: (config: Collection) => void;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.collection = void 0;
4
+ const collection = (config) => { };
5
+ exports.collection = collection;
@@ -0,0 +1 @@
1
+ export * from './define';
@@ -0,0 +1,17 @@
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("./define"), exports);
@@ -0,0 +1,11 @@
1
+ export type Collection = {
2
+ slug: string;
3
+ name?: string;
4
+ admin?: {
5
+ title?: string;
6
+ group?: string;
7
+ };
8
+ fields: {
9
+ [key: string]: string;
10
+ };
11
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import { Config } from "./types";
2
+ export declare const defineConfig: (config: Config) => void;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineConfig = void 0;
4
+ const defineConfig = (config) => { };
5
+ exports.defineConfig = defineConfig;
@@ -0,0 +1,4 @@
1
+ import { Collection } from "../collections/types";
2
+ export type Config = {
3
+ collections: Collection[];
4
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ import z from "zod";
2
+ import { Field, FieldConfig, FieldTypeConfig, FieldTypeFinal } from "./types";
3
+ export declare const fieldType: <TParams extends z.ZodType>(config: FieldTypeConfig<TParams>) => (params: z.infer<TParams>) => FieldTypeFinal<TParams>;
4
+ export declare const field: <TType extends FieldTypeConfig>(config: FieldConfig<TType>) => Field<TType>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.field = exports.fieldType = void 0;
4
+ const fieldType = (config) => (params) => {
5
+ const validated = config.schema.parse(params);
6
+ return {
7
+ kind: config.dsl.kind,
8
+ params: validated,
9
+ dsl: config.dsl,
10
+ admin: config.admin,
11
+ };
12
+ };
13
+ exports.fieldType = fieldType;
14
+ const defaultPermissions = {
15
+ create: async () => true,
16
+ read: async () => true,
17
+ update: async () => true,
18
+ delete: async () => true,
19
+ };
20
+ const field = (config) => {
21
+ return {
22
+ type: config.type,
23
+ permissions: {
24
+ ...defaultPermissions,
25
+ ...config.permissions,
26
+ },
27
+ };
28
+ };
29
+ exports.field = field;
@@ -0,0 +1,2 @@
1
+ export * from './field';
2
+ export * from './types';
@@ -0,0 +1,18 @@
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("./field"), exports);
18
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,36 @@
1
+ import { z } from "zod";
2
+ export type FieldTypeConfig<TParams extends z.ZodType = z.ZodType> = {
3
+ schema: TParams;
4
+ dsl: {
5
+ kind: string;
6
+ config?: Record<string, any>;
7
+ };
8
+ admin: {
9
+ component: any;
10
+ };
11
+ };
12
+ export type FieldTypeFinal<TParams extends z.ZodType = z.ZodType> = {
13
+ kind: string;
14
+ params: z.infer<TParams>;
15
+ dsl: {
16
+ kind: string;
17
+ config?: Record<string, any>;
18
+ };
19
+ admin: {
20
+ component: any;
21
+ };
22
+ };
23
+ export type FieldPermissions = {
24
+ create: (ctx: any) => Promise<boolean>;
25
+ read: (ctx: any) => Promise<boolean>;
26
+ update: (ctx: any) => Promise<boolean>;
27
+ delete: (ctx: any) => Promise<boolean>;
28
+ };
29
+ export type FieldConfig<TType extends FieldTypeConfig> = {
30
+ type: TType;
31
+ permissions?: Partial<FieldPermissions>;
32
+ };
33
+ export type Field<TType extends FieldTypeConfig = FieldTypeConfig> = {
34
+ type: TType;
35
+ permissions: FieldPermissions;
36
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export * from './config';
2
+ export * from './collections';
3
+ export * from './fields';
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("./config"), exports);
18
+ __exportStar(require("./collections"), exports);
19
+ __exportStar(require("./fields"), exports);
@@ -0,0 +1,3 @@
1
+ export type DeepPartial<T> = T extends (infer U)[] ? DeepPartial<U>[] : T extends object ? {
2
+ [K in keyof T]?: DeepPartial<T[K]>;
3
+ } : T;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,19 +1,62 @@
1
- {
2
- "name": "@deessejs/collections",
3
- "version": "0.0.2",
4
- "description": "",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/Developers-Secrets-Inc/collections.git"
12
- },
13
- "author": "",
14
- "license": "ISC",
15
- "bugs": {
16
- "url": "https://github.com/Developers-Secrets-Inc/collections/issues"
17
- },
18
- "homepage": "https://github.com/Developers-Secrets-Inc/collections#readme"
19
- }
1
+ {
2
+ "name": "@deessejs/collections",
3
+ "version": "0.0.4",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "module": "dist/index.esm.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.esm.js",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist/**/*",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc",
22
+ "build:watch": "tsc --watch",
23
+ "prepublishOnly": "npm run build",
24
+ "lint": "eslint src --ext .ts",
25
+ "lint:fix": "eslint src --ext .ts --fix",
26
+ "test": "vitest",
27
+ "test:ui": "vitest --ui",
28
+ "test:run": "vitest run",
29
+ "test:coverage": "vitest run --coverage",
30
+ "test:watch": "vitest watch"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/Developers-Secrets-Inc/collections.git"
35
+ },
36
+ "author": "",
37
+ "license": "ISC",
38
+ "bugs": {
39
+ "url": "https://github.com/Developers-Secrets-Inc/collections/issues"
40
+ },
41
+ "homepage": "https://github.com/Developers-Secrets-Inc/collections#readme",
42
+ "devDependencies": {
43
+ "zod": "^4.1.12",
44
+ "@testing-library/dom": "^10.4.1",
45
+ "@testing-library/user-event": "^14.6.1",
46
+ "@types/jsdom": "^27.0.0",
47
+ "@types/node": "^20.0.0",
48
+ "@types/sinon": "^21.0.0",
49
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
50
+ "@typescript-eslint/parser": "^6.0.0",
51
+ "@vitest/coverage-v8": "^4.0.13",
52
+ "@vitest/ui": "^4.0.13",
53
+ "eslint": "^8.0.0",
54
+ "jsdom": "^27.2.0",
55
+ "sinon": "^21.0.0",
56
+ "typescript": "^5.0.0",
57
+ "vitest": "^4.0.13"
58
+ },
59
+ "peerDependencies": {
60
+ "zod": "^4.1.12"
61
+ }
62
+ }
@@ -1 +0,0 @@
1
- export const defineConfig = () => {};
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './config'