@deessejs/collections 0.0.3 → 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.
@@ -1 +1,2 @@
1
- export declare const collections: () => void;
1
+ import { Collection } from "./types";
2
+ export declare const collection: (config: Collection) => void;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.collections = void 0;
4
- const collections = () => { };
5
- exports.collections = collections;
3
+ exports.collection = void 0;
4
+ const collection = (config) => { };
5
+ exports.collection = collection;
@@ -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 });
@@ -1 +1,2 @@
1
- export declare const defineConfig: () => void;
1
+ import { Config } from "./types";
2
+ export declare const defineConfig: (config: Config) => void;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defineConfig = void 0;
4
- const defineConfig = () => { };
4
+ const defineConfig = (config) => { };
5
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 });
@@ -1 +1,4 @@
1
- export declare const field: () => void;
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>;
@@ -1,5 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.field = void 0;
4
- const field = () => { };
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
+ };
5
29
  exports.field = field;
@@ -1 +1,2 @@
1
1
  export * from './field';
2
+ export * from './types';
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
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 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,38 +1,62 @@
1
- {
2
- "name": "@deessejs/collections",
3
- "version": "0.0.3",
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
- "test": "echo \"Error: no test specified\" && exit 1",
25
- "lint": "eslint src --ext .ts",
26
- "lint:fix": "eslint src --ext .ts --fix"
27
- },
28
- "repository": {
29
- "type": "git",
30
- "url": "git+https://github.com/Developers-Secrets-Inc/collections.git"
31
- },
32
- "author": "",
33
- "license": "ISC",
34
- "bugs": {
35
- "url": "https://github.com/Developers-Secrets-Inc/collections/issues"
36
- },
37
- "homepage": "https://github.com/Developers-Secrets-Inc/collections#readme"
38
- }
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
+ }