pocketbase-zod-schema 0.1.2

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 (94) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE +21 -0
  3. package/README.md +167 -0
  4. package/dist/cli/index.cjs +3383 -0
  5. package/dist/cli/index.cjs.map +1 -0
  6. package/dist/cli/index.d.cts +30 -0
  7. package/dist/cli/index.d.ts +30 -0
  8. package/dist/cli/index.js +3331 -0
  9. package/dist/cli/index.js.map +1 -0
  10. package/dist/cli/migrate.cjs +3380 -0
  11. package/dist/cli/migrate.cjs.map +1 -0
  12. package/dist/cli/migrate.d.cts +1 -0
  13. package/dist/cli/migrate.d.ts +1 -0
  14. package/dist/cli/migrate.js +3353 -0
  15. package/dist/cli/migrate.js.map +1 -0
  16. package/dist/cli/utils/index.cjs +540 -0
  17. package/dist/cli/utils/index.cjs.map +1 -0
  18. package/dist/cli/utils/index.d.cts +232 -0
  19. package/dist/cli/utils/index.d.ts +232 -0
  20. package/dist/cli/utils/index.js +487 -0
  21. package/dist/cli/utils/index.js.map +1 -0
  22. package/dist/enums.cjs +19 -0
  23. package/dist/enums.cjs.map +1 -0
  24. package/dist/enums.d.cts +6 -0
  25. package/dist/enums.d.ts +6 -0
  26. package/dist/enums.js +17 -0
  27. package/dist/enums.js.map +1 -0
  28. package/dist/index.cjs +4900 -0
  29. package/dist/index.cjs.map +1 -0
  30. package/dist/index.d.cts +18 -0
  31. package/dist/index.d.ts +18 -0
  32. package/dist/index.js +4726 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/migration/analyzer.cjs +1267 -0
  35. package/dist/migration/analyzer.cjs.map +1 -0
  36. package/dist/migration/analyzer.d.cts +186 -0
  37. package/dist/migration/analyzer.d.ts +186 -0
  38. package/dist/migration/analyzer.js +1232 -0
  39. package/dist/migration/analyzer.js.map +1 -0
  40. package/dist/migration/diff.cjs +557 -0
  41. package/dist/migration/diff.cjs.map +1 -0
  42. package/dist/migration/diff.d.cts +291 -0
  43. package/dist/migration/diff.d.ts +291 -0
  44. package/dist/migration/diff.js +534 -0
  45. package/dist/migration/diff.js.map +1 -0
  46. package/dist/migration/generator.cjs +778 -0
  47. package/dist/migration/generator.cjs.map +1 -0
  48. package/dist/migration/generator.d.cts +225 -0
  49. package/dist/migration/generator.d.ts +225 -0
  50. package/dist/migration/generator.js +737 -0
  51. package/dist/migration/generator.js.map +1 -0
  52. package/dist/migration/index.cjs +3390 -0
  53. package/dist/migration/index.cjs.map +1 -0
  54. package/dist/migration/index.d.cts +103 -0
  55. package/dist/migration/index.d.ts +103 -0
  56. package/dist/migration/index.js +3265 -0
  57. package/dist/migration/index.js.map +1 -0
  58. package/dist/migration/snapshot.cjs +609 -0
  59. package/dist/migration/snapshot.cjs.map +1 -0
  60. package/dist/migration/snapshot.d.cts +167 -0
  61. package/dist/migration/snapshot.d.ts +167 -0
  62. package/dist/migration/snapshot.js +575 -0
  63. package/dist/migration/snapshot.js.map +1 -0
  64. package/dist/migration/utils/index.cjs +672 -0
  65. package/dist/migration/utils/index.cjs.map +1 -0
  66. package/dist/migration/utils/index.d.cts +207 -0
  67. package/dist/migration/utils/index.d.ts +207 -0
  68. package/dist/migration/utils/index.js +641 -0
  69. package/dist/migration/utils/index.js.map +1 -0
  70. package/dist/mutator.cjs +427 -0
  71. package/dist/mutator.cjs.map +1 -0
  72. package/dist/mutator.d.cts +190 -0
  73. package/dist/mutator.d.ts +190 -0
  74. package/dist/mutator.js +425 -0
  75. package/dist/mutator.js.map +1 -0
  76. package/dist/permissions-ZHafVSIx.d.cts +71 -0
  77. package/dist/permissions-ZHafVSIx.d.ts +71 -0
  78. package/dist/schema.cjs +430 -0
  79. package/dist/schema.cjs.map +1 -0
  80. package/dist/schema.d.cts +316 -0
  81. package/dist/schema.d.ts +316 -0
  82. package/dist/schema.js +396 -0
  83. package/dist/schema.js.map +1 -0
  84. package/dist/types-BbTgmg6H.d.cts +91 -0
  85. package/dist/types-z1Dkjg8m.d.ts +91 -0
  86. package/dist/types.cjs +4 -0
  87. package/dist/types.cjs.map +1 -0
  88. package/dist/types.d.cts +14 -0
  89. package/dist/types.d.ts +14 -0
  90. package/dist/types.js +3 -0
  91. package/dist/types.js.map +1 -0
  92. package/dist/user-jS1aYoeD.d.cts +123 -0
  93. package/dist/user-jS1aYoeD.d.ts +123 -0
  94. package/package.json +165 -0
@@ -0,0 +1,14 @@
1
+ import PocketBase__default, { RecordService } from 'pocketbase';
2
+ import { z } from 'zod';
3
+ import { b as UserSchema, a as ProjectSchema, U as UserInputSchema, P as ProjectInputSchema } from './user-jS1aYoeD.cjs';
4
+
5
+ type ProjectInputType = z.infer<typeof ProjectInputSchema>;
6
+ type ProjectType = z.infer<typeof ProjectSchema>;
7
+ type UserInputType = z.infer<typeof UserInputSchema>;
8
+ type UserType = z.infer<typeof UserSchema>;
9
+ interface TypedPocketBase extends PocketBase__default {
10
+ collection(idOrName: "Users"): RecordService<UserType>;
11
+ collection(idOrName: "Projects"): RecordService<ProjectType>;
12
+ }
13
+
14
+ export type { ProjectInputType, ProjectType, TypedPocketBase, UserInputType, UserType };
@@ -0,0 +1,14 @@
1
+ import PocketBase__default, { RecordService } from 'pocketbase';
2
+ import { z } from 'zod';
3
+ import { b as UserSchema, a as ProjectSchema, U as UserInputSchema, P as ProjectInputSchema } from './user-jS1aYoeD.js';
4
+
5
+ type ProjectInputType = z.infer<typeof ProjectInputSchema>;
6
+ type ProjectType = z.infer<typeof ProjectSchema>;
7
+ type UserInputType = z.infer<typeof UserInputSchema>;
8
+ type UserType = z.infer<typeof UserSchema>;
9
+ interface TypedPocketBase extends PocketBase__default {
10
+ collection(idOrName: "Users"): RecordService<UserType>;
11
+ collection(idOrName: "Projects"): RecordService<ProjectType>;
12
+ }
13
+
14
+ export type { ProjectInputType, ProjectType, TypedPocketBase, UserInputType, UserType };
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=types.js.map
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"types.js","sourcesContent":[]}
@@ -0,0 +1,123 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const ProjectInputSchema: z.ZodObject<{
4
+ title: z.ZodString;
5
+ content: z.ZodString;
6
+ status: z.ZodEnum<["draft", "active", "complete", "fail"]>;
7
+ summary: z.ZodOptional<z.ZodString>;
8
+ User: z.ZodString;
9
+ SubscriberUsers: z.ZodArray<z.ZodString, "many">;
10
+ } & {
11
+ imageFiles: z.ZodArray<z.ZodType<File, z.ZodTypeDef, File>, "many">;
12
+ }, "strip", z.ZodTypeAny, {
13
+ status: "draft" | "active" | "complete" | "fail";
14
+ User: string;
15
+ title: string;
16
+ content: string;
17
+ SubscriberUsers: string[];
18
+ imageFiles: File[];
19
+ summary?: string | undefined;
20
+ }, {
21
+ status: "draft" | "active" | "complete" | "fail";
22
+ User: string;
23
+ title: string;
24
+ content: string;
25
+ SubscriberUsers: string[];
26
+ imageFiles: File[];
27
+ summary?: string | undefined;
28
+ }>;
29
+ declare const ProjectSchema: z.ZodObject<Omit<{
30
+ title: z.ZodString;
31
+ content: z.ZodString;
32
+ status: z.ZodEnum<["draft", "active", "complete", "fail"]>;
33
+ summary: z.ZodOptional<z.ZodString>;
34
+ User: z.ZodString;
35
+ SubscriberUsers: z.ZodArray<z.ZodString, "many">;
36
+ } & {
37
+ imageFiles: z.ZodArray<z.ZodType<File, z.ZodTypeDef, File>, "many">;
38
+ }, "imageFiles"> & {
39
+ thumbnailURL: z.ZodOptional<z.ZodString>;
40
+ imageFiles: z.ZodArray<z.ZodString, "many">;
41
+ id: z.ZodString;
42
+ collectionId: z.ZodString;
43
+ collectionName: z.ZodString;
44
+ expand: z.ZodRecord<z.ZodString, z.ZodAny>;
45
+ }, "strip", z.ZodTypeAny, {
46
+ status: "draft" | "active" | "complete" | "fail";
47
+ User: string;
48
+ title: string;
49
+ content: string;
50
+ SubscriberUsers: string[];
51
+ imageFiles: string[];
52
+ id: string;
53
+ collectionId: string;
54
+ collectionName: string;
55
+ expand: Record<string, any>;
56
+ summary?: string | undefined;
57
+ thumbnailURL?: string | undefined;
58
+ }, {
59
+ status: "draft" | "active" | "complete" | "fail";
60
+ User: string;
61
+ title: string;
62
+ content: string;
63
+ SubscriberUsers: string[];
64
+ imageFiles: string[];
65
+ id: string;
66
+ collectionId: string;
67
+ collectionName: string;
68
+ expand: Record<string, any>;
69
+ summary?: string | undefined;
70
+ thumbnailURL?: string | undefined;
71
+ }>;
72
+
73
+ /** -- User Collections -- */
74
+ declare const UserInputSchema: z.ZodObject<{
75
+ name: z.ZodOptional<z.ZodString>;
76
+ email: z.ZodString;
77
+ password: z.ZodString;
78
+ passwordConfirm: z.ZodString;
79
+ avatar: z.ZodOptional<z.ZodType<File, z.ZodTypeDef, File>>;
80
+ }, "strip", z.ZodTypeAny, {
81
+ email: string;
82
+ password: string;
83
+ passwordConfirm: string;
84
+ name?: string | undefined;
85
+ avatar?: File | undefined;
86
+ }, {
87
+ email: string;
88
+ password: string;
89
+ passwordConfirm: string;
90
+ name?: string | undefined;
91
+ avatar?: File | undefined;
92
+ }>;
93
+ declare const UserSchema: z.ZodObject<{
94
+ name: z.ZodOptional<z.ZodString>;
95
+ email: z.ZodString;
96
+ password: z.ZodString;
97
+ avatar: z.ZodOptional<z.ZodType<File, z.ZodTypeDef, File>>;
98
+ } & {
99
+ id: z.ZodString;
100
+ collectionId: z.ZodString;
101
+ collectionName: z.ZodString;
102
+ expand: z.ZodRecord<z.ZodString, z.ZodAny>;
103
+ }, "strip", z.ZodTypeAny, {
104
+ id: string;
105
+ collectionId: string;
106
+ collectionName: string;
107
+ expand: Record<string, any>;
108
+ email: string;
109
+ password: string;
110
+ name?: string | undefined;
111
+ avatar?: File | undefined;
112
+ }, {
113
+ id: string;
114
+ collectionId: string;
115
+ collectionName: string;
116
+ expand: Record<string, any>;
117
+ email: string;
118
+ password: string;
119
+ name?: string | undefined;
120
+ avatar?: File | undefined;
121
+ }>;
122
+
123
+ export { ProjectInputSchema as P, UserInputSchema as U, ProjectSchema as a, UserSchema as b };
@@ -0,0 +1,123 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const ProjectInputSchema: z.ZodObject<{
4
+ title: z.ZodString;
5
+ content: z.ZodString;
6
+ status: z.ZodEnum<["draft", "active", "complete", "fail"]>;
7
+ summary: z.ZodOptional<z.ZodString>;
8
+ User: z.ZodString;
9
+ SubscriberUsers: z.ZodArray<z.ZodString, "many">;
10
+ } & {
11
+ imageFiles: z.ZodArray<z.ZodType<File, z.ZodTypeDef, File>, "many">;
12
+ }, "strip", z.ZodTypeAny, {
13
+ status: "draft" | "active" | "complete" | "fail";
14
+ User: string;
15
+ title: string;
16
+ content: string;
17
+ SubscriberUsers: string[];
18
+ imageFiles: File[];
19
+ summary?: string | undefined;
20
+ }, {
21
+ status: "draft" | "active" | "complete" | "fail";
22
+ User: string;
23
+ title: string;
24
+ content: string;
25
+ SubscriberUsers: string[];
26
+ imageFiles: File[];
27
+ summary?: string | undefined;
28
+ }>;
29
+ declare const ProjectSchema: z.ZodObject<Omit<{
30
+ title: z.ZodString;
31
+ content: z.ZodString;
32
+ status: z.ZodEnum<["draft", "active", "complete", "fail"]>;
33
+ summary: z.ZodOptional<z.ZodString>;
34
+ User: z.ZodString;
35
+ SubscriberUsers: z.ZodArray<z.ZodString, "many">;
36
+ } & {
37
+ imageFiles: z.ZodArray<z.ZodType<File, z.ZodTypeDef, File>, "many">;
38
+ }, "imageFiles"> & {
39
+ thumbnailURL: z.ZodOptional<z.ZodString>;
40
+ imageFiles: z.ZodArray<z.ZodString, "many">;
41
+ id: z.ZodString;
42
+ collectionId: z.ZodString;
43
+ collectionName: z.ZodString;
44
+ expand: z.ZodRecord<z.ZodString, z.ZodAny>;
45
+ }, "strip", z.ZodTypeAny, {
46
+ status: "draft" | "active" | "complete" | "fail";
47
+ User: string;
48
+ title: string;
49
+ content: string;
50
+ SubscriberUsers: string[];
51
+ imageFiles: string[];
52
+ id: string;
53
+ collectionId: string;
54
+ collectionName: string;
55
+ expand: Record<string, any>;
56
+ summary?: string | undefined;
57
+ thumbnailURL?: string | undefined;
58
+ }, {
59
+ status: "draft" | "active" | "complete" | "fail";
60
+ User: string;
61
+ title: string;
62
+ content: string;
63
+ SubscriberUsers: string[];
64
+ imageFiles: string[];
65
+ id: string;
66
+ collectionId: string;
67
+ collectionName: string;
68
+ expand: Record<string, any>;
69
+ summary?: string | undefined;
70
+ thumbnailURL?: string | undefined;
71
+ }>;
72
+
73
+ /** -- User Collections -- */
74
+ declare const UserInputSchema: z.ZodObject<{
75
+ name: z.ZodOptional<z.ZodString>;
76
+ email: z.ZodString;
77
+ password: z.ZodString;
78
+ passwordConfirm: z.ZodString;
79
+ avatar: z.ZodOptional<z.ZodType<File, z.ZodTypeDef, File>>;
80
+ }, "strip", z.ZodTypeAny, {
81
+ email: string;
82
+ password: string;
83
+ passwordConfirm: string;
84
+ name?: string | undefined;
85
+ avatar?: File | undefined;
86
+ }, {
87
+ email: string;
88
+ password: string;
89
+ passwordConfirm: string;
90
+ name?: string | undefined;
91
+ avatar?: File | undefined;
92
+ }>;
93
+ declare const UserSchema: z.ZodObject<{
94
+ name: z.ZodOptional<z.ZodString>;
95
+ email: z.ZodString;
96
+ password: z.ZodString;
97
+ avatar: z.ZodOptional<z.ZodType<File, z.ZodTypeDef, File>>;
98
+ } & {
99
+ id: z.ZodString;
100
+ collectionId: z.ZodString;
101
+ collectionName: z.ZodString;
102
+ expand: z.ZodRecord<z.ZodString, z.ZodAny>;
103
+ }, "strip", z.ZodTypeAny, {
104
+ id: string;
105
+ collectionId: string;
106
+ collectionName: string;
107
+ expand: Record<string, any>;
108
+ email: string;
109
+ password: string;
110
+ name?: string | undefined;
111
+ avatar?: File | undefined;
112
+ }, {
113
+ id: string;
114
+ collectionId: string;
115
+ collectionName: string;
116
+ expand: Record<string, any>;
117
+ email: string;
118
+ password: string;
119
+ name?: string | undefined;
120
+ avatar?: File | undefined;
121
+ }>;
122
+
123
+ export { ProjectInputSchema as P, UserInputSchema as U, ProjectSchema as a, UserSchema as b };
package/package.json ADDED
@@ -0,0 +1,165 @@
1
+ {
2
+ "name": "pocketbase-zod-schema",
3
+ "version": "0.1.2",
4
+ "description": "PocketBase migration generator using Zod schemas for type-safe database migrations",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "keywords": [
10
+ "pocketbase",
11
+ "zod",
12
+ "migration",
13
+ "database",
14
+ "typescript",
15
+ "schema",
16
+ "sqlite",
17
+ "orm",
18
+ "type-safe",
19
+ "code-generation"
20
+ ],
21
+ "homepage": "https://github.com/dastron/pocketbase-zod-schema#readme",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/dastron/pocketbase-zod-schema.git"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/dastron/pocketbase-zod-schema/issues"
28
+ },
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js",
33
+ "require": "./dist/index.cjs"
34
+ },
35
+ "./schema": {
36
+ "types": "./dist/schema.d.ts",
37
+ "import": "./dist/schema.js",
38
+ "require": "./dist/schema.cjs"
39
+ },
40
+ "./enums": {
41
+ "types": "./dist/enums.d.ts",
42
+ "import": "./dist/enums.js",
43
+ "require": "./dist/enums.cjs"
44
+ },
45
+ "./types": {
46
+ "types": "./dist/types.d.ts",
47
+ "import": "./dist/types.js",
48
+ "require": "./dist/types.cjs"
49
+ },
50
+ "./mutator": {
51
+ "types": "./dist/mutator.d.ts",
52
+ "import": "./dist/mutator.js",
53
+ "require": "./dist/mutator.cjs"
54
+ },
55
+ "./migration": {
56
+ "types": "./dist/migration/index.d.ts",
57
+ "import": "./dist/migration/index.js",
58
+ "require": "./dist/migration/index.cjs"
59
+ },
60
+ "./migration/analyzer": {
61
+ "types": "./dist/migration/analyzer.d.ts",
62
+ "import": "./dist/migration/analyzer.js",
63
+ "require": "./dist/migration/analyzer.cjs"
64
+ },
65
+ "./migration/diff": {
66
+ "types": "./dist/migration/diff.d.ts",
67
+ "import": "./dist/migration/diff.js",
68
+ "require": "./dist/migration/diff.cjs"
69
+ },
70
+ "./migration/generator": {
71
+ "types": "./dist/migration/generator.d.ts",
72
+ "import": "./dist/migration/generator.js",
73
+ "require": "./dist/migration/generator.cjs"
74
+ },
75
+ "./migration/snapshot": {
76
+ "types": "./dist/migration/snapshot.d.ts",
77
+ "import": "./dist/migration/snapshot.js",
78
+ "require": "./dist/migration/snapshot.cjs"
79
+ },
80
+ "./migration/utils": {
81
+ "types": "./dist/migration/utils/index.d.ts",
82
+ "import": "./dist/migration/utils/index.js",
83
+ "require": "./dist/migration/utils/index.cjs"
84
+ },
85
+ "./cli": {
86
+ "types": "./dist/cli/index.d.ts",
87
+ "import": "./dist/cli/index.js",
88
+ "require": "./dist/cli/index.cjs"
89
+ },
90
+ "./cli/utils": {
91
+ "types": "./dist/cli/utils/index.d.ts",
92
+ "import": "./dist/cli/utils/index.js",
93
+ "require": "./dist/cli/utils/index.cjs"
94
+ },
95
+ "./package.json": "./package.json"
96
+ },
97
+ "files": [
98
+ "dist",
99
+ "README.md",
100
+ "LICENSE",
101
+ "CHANGELOG.md",
102
+ "API.md",
103
+ "MIGRATION_GUIDE.md"
104
+ ],
105
+ "scripts": {
106
+ "build": "tsup",
107
+ "dev": "nodemon",
108
+ "test": "vitest run",
109
+ "test:watch": "vitest",
110
+ "test:coverage": "vitest run --coverage",
111
+ "test:property": "vitest run --testNamePattern='Property'",
112
+ "typecheck": "tsc --noEmit",
113
+ "format": "prettier --write ./src",
114
+ "lint": "eslint src --fix",
115
+ "clean": "rm -rf dist",
116
+ "bundle-size": "yarn build && du -sh dist/* | sort -hr",
117
+ "prepublishOnly": "yarn clean && yarn build && yarn test",
118
+ "publish:npm": "node ../scripts/publish-npm.js",
119
+ "publish:npm:env": "node --env-file ../.env ../scripts/publish-npm.js",
120
+ "check-updates": "yarn outdated"
121
+ },
122
+ "bin": {
123
+ "pocketbase-migrate": "./dist/cli/migrate.js"
124
+ },
125
+ "engines": {
126
+ "node": ">=20.0.0"
127
+ },
128
+ "author": "dastron <erik.danford@gmail.com>",
129
+ "license": "MIT",
130
+ "sideEffects": false,
131
+ "bundleDependencies": false,
132
+ "peerDependencies": {
133
+ "zod": "^3.20.0"
134
+ },
135
+ "peerDependenciesMeta": {
136
+ "zod": {
137
+ "optional": false
138
+ }
139
+ },
140
+ "devDependencies": {
141
+ "@babel/parser": "^7.28.5",
142
+ "@eslint/js": "^9.39.2",
143
+ "@types/node": "^22.14.1",
144
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
145
+ "@typescript-eslint/parser": "^8.0.0",
146
+ "@vitest/coverage-v8": "^3.1.2",
147
+ "diff": "^8.0.2",
148
+ "eslint": "^9.0.0",
149
+ "fast-check": "^4.3.0",
150
+ "nodemon": "^3.1.9",
151
+ "prettier": "^3.5.3",
152
+ "prettier-plugin-organize-imports": "^4.1.0",
153
+ "tsup": "^8.4.0",
154
+ "typescript": "^5.8.3",
155
+ "typescript-eslint": "^8.50.0",
156
+ "vitest": "^3.1.2"
157
+ },
158
+ "dependencies": {
159
+ "chalk": "^5.3.0",
160
+ "commander": "^12.0.0",
161
+ "ora": "^8.0.1",
162
+ "pocketbase": "^0.26.0",
163
+ "zod": "^3.24.3"
164
+ }
165
+ }