drizzle-kit 0.9.1 → 0.9.5

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 (55) hide show
  1. package/drizzle.js +4 -0
  2. package/drizzle.js.map +1 -0
  3. package/package.json +5 -2
  4. package/.eslintrc +0 -21
  5. package/config.yml +0 -4
  6. package/data/_prev/multi.ts +0 -43
  7. package/data/_prev/tables/authOtpTable.ts +0 -22
  8. package/data/_prev/tables/cityTable.ts +0 -17
  9. package/data/_prev/tables/usersTable.ts +0 -18
  10. package/data/_prev/types/types.ts +0 -11
  11. package/data/v1/tables/authOtpTable.ts +0 -18
  12. package/data/v1/tables/deletedTable.ts +0 -9
  13. package/data/v1/tables/usersTable.ts +0 -15
  14. package/data/v1/types/types.ts +0 -6
  15. package/data/v2/tables/authOtpTable.ts +0 -22
  16. package/data/v2/tables/cityTable.ts +0 -10
  17. package/data/v2/tables/usersTable.ts +0 -19
  18. package/data/v2/types/types.ts +0 -11
  19. package/data/v3/tables/authOtpTable.ts +0 -21
  20. package/data/v3/tables/cityTable.ts +0 -17
  21. package/data/v3/tables/usersTable.ts +0 -18
  22. package/data/v3/types/types.ts +0 -11
  23. package/factory.ts +0 -224
  24. package/fstest.ts +0 -50
  25. package/index.ts +0 -16
  26. package/readme.md +0 -9
  27. package/serializer.ts +0 -139
  28. package/src/cli/commands/migration/index.tsx +0 -10
  29. package/src/cli/commands/migration/migrate/index.tsx +0 -164
  30. package/src/cli/components-api/ComponentsList.tsx +0 -20
  31. package/src/cli/components-api/CreateApp.tsx +0 -19
  32. package/src/cli/components-api/components/PromptColumnsConflicts.tsx +0 -171
  33. package/src/cli/components-api/components/PromptTablesConflicts.tsx +0 -180
  34. package/src/cli/components-api/components/Task.tsx +0 -85
  35. package/src/cli/components-api/index.tsx +0 -76
  36. package/src/cli/enq.ts +0 -41
  37. package/src/cli/index.tsx +0 -8
  38. package/src/cli/machines/resolveColumnsMachine.ts +0 -179
  39. package/src/cli/machines/resolveTablesMachine.ts +0 -169
  40. package/src/cli/utils/formatDataForTable.ts +0 -36
  41. package/src/cli/utils/valuesForPrompts.ts +0 -35
  42. package/src/diff.ts +0 -272
  43. package/src/differ.js +0 -135
  44. package/src/jsonStatements.js +0 -176
  45. package/src/migrationPreparator.ts +0 -47
  46. package/src/serilizer/factory.ts +0 -340
  47. package/src/serilizer/index.ts +0 -25
  48. package/src/simulator.ts +0 -85
  49. package/src/sqlgenerator.js +0 -373
  50. package/test-build.js +0 -26
  51. package/test.ts +0 -57
  52. package/testFactory.js +0 -3
  53. package/testFactory.ts +0 -26
  54. package/tsconfig.json +0 -28
  55. package/webpack.config.js +0 -53
@@ -1,76 +0,0 @@
1
- import React from 'react';
2
- import { proxy } from 'valtio';
3
-
4
- import {
5
- ColumnsResultData,
6
- Named,
7
- TablesResultData,
8
- } from 'cli/commands/migration/migrate';
9
- import Task, { CallbackProps } from 'cli/components-api/components/Task';
10
- import createApp from 'cli/components-api/CreateApp';
11
- import { TableWithColumn } from 'cli/machines/resolveColumnsMachine';
12
- import PromptTablesConflicts, { RenderTablesSelectProps } from 'cli/components-api/components/PromptTablesConflicts';
13
- import PromptColumnsConflicts from 'cli/components-api/components/PromptColumnsConflicts';
14
-
15
- const componentsList = proxy<React.ReactElement<any, any>[]>([]);
16
- let app: ReturnType<typeof createApp>;
17
-
18
- export interface CreateTaskParams<In, Cbs> {
19
- input: In,
20
- run: (cbs: Cbs) => void
21
- }
22
-
23
- const prepareApp = () => {
24
- if (!app) {
25
- app = createApp(componentsList);
26
- componentsList.length = 0;
27
- }
28
- };
29
-
30
- export const task = <T extends unknown>(
31
- titleStr: string,
32
- func: (props: CallbackProps) => T,
33
- ) => new Promise<T>((
34
- resolve,
35
- ) => {
36
- prepareApp();
37
-
38
- componentsList.push(
39
- <Task
40
- titleStr={titleStr}
41
- func={func}
42
- onDone={(val: T) => resolve(val)}
43
- />,
44
- );
45
- });
46
-
47
- export const promptTablesConflicts = <T extends Named>(
48
- { missingTables, newTables }: RenderTablesSelectProps<T>,
49
- ) => new Promise<TablesResultData<T>>((
50
- resolve,
51
- ) => {
52
- prepareApp();
53
-
54
- componentsList.push(
55
- <PromptTablesConflicts
56
- onDone={(val) => resolve(val)}
57
- missingTables={missingTables}
58
- newTables={newTables}
59
- />,
60
- );
61
- });
62
-
63
- export const promptColumnsConflicts = (
64
- tableWithColumns: TableWithColumn,
65
- ) => new Promise<ColumnsResultData<Named>>((
66
- resolve,
67
- ) => {
68
- prepareApp();
69
-
70
- componentsList.push(
71
- <PromptColumnsConflicts
72
- onDone={(val) => resolve(val)}
73
- tableWithColumns={tableWithColumns}
74
- />,
75
- );
76
- });
package/src/cli/enq.ts DELETED
@@ -1,41 +0,0 @@
1
- import { Command } from 'commander'
2
- import fs from 'fs'
3
-
4
- const main = async () => {
5
- const program = new Command()
6
- .arguments("[input]")
7
-
8
- // const addCommand = new Command('add')
9
- // program.addCommand(addCommand)
10
- program.parse(process.argv)
11
-
12
-
13
- if (program.args.length === 0) {
14
- return
15
- }
16
-
17
- console.log(program.args)
18
- const [input] = program.args
19
- if (input === 'add') {
20
- //todo add item
21
- // // const exampleLink = terminalLink('here', 'https://google.com')
22
- // console.log(`Example see ${exampleLink}`)
23
- // console.log(exampleLink)
24
- // try {
25
- // const newEntry = await prepareNewEntry()
26
- // newEntry.secret
27
- // } catch (_) { }
28
- return
29
- }
30
-
31
- if (fs.existsSync(input)) {
32
- // handle file
33
- console.log('handle file')
34
- return
35
- }
36
-
37
- console.log('is encoded secret',)
38
- }
39
-
40
-
41
- main()
package/src/cli/index.tsx DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
- import { program } from 'commander';
3
- import 'source-map-support/register';
4
- import 'pretty-error/start';
5
-
6
- import './commands/migration';
7
-
8
- program.parse();
@@ -1,179 +0,0 @@
1
- import { assign, createMachine, send } from 'xstate';
2
- import { Named, RenamedObject } from 'cli/commands/migration/migrate';
3
-
4
- type Event =
5
- | { type: 'CHOICE_ITEM', itemIndex: number }
6
- | { type: 'DELETE' }
7
- | { type: 'RENAME' }
8
- | { type: 'CANCEL' }
9
- | { type: 'CONFIRM' }
10
- | { type: 'NEXT' }
11
- | { type: 'CHOICE_NEW_ITEM'; itemIndex: number };
12
-
13
- export interface TableWithColumn {
14
- name: string;
15
- added: Named[],
16
- deleted: Named[],
17
- }
18
-
19
- interface Props {
20
- tableWithColumns: TableWithColumn,
21
- }
22
-
23
- interface Context {
24
- tableName: string,
25
- addedColumns: Named[],
26
- deletedColumns: Named[],
27
- missingItemIndex: number,
28
- newItemIndex: number,
29
- created: Named[];
30
- renamed: RenamedObject<Named>[];
31
- deleted: Named[];
32
- }
33
-
34
- const createResolveColumnsMachine = (props: Props) => (
35
- createMachine<Context, Event>({
36
- id: 'resolveColumns',
37
- initial: 'table',
38
- context: {
39
- tableName: props.tableWithColumns.name,
40
- addedColumns: props.tableWithColumns.added,
41
- deletedColumns: props.tableWithColumns.deleted,
42
- missingItemIndex: 0,
43
- newItemIndex: 0,
44
- created: [],
45
- renamed: [],
46
- deleted: [],
47
- },
48
- states: {
49
- table: {
50
- entry: send({ type: 'NEXT' }),
51
- on: {
52
- NEXT: [
53
- {
54
- target: 'done',
55
- cond: 'isMissingColumnsResolved',
56
- actions: ['resolveRemaining'],
57
- },
58
- {
59
- target: 'done',
60
- cond: 'isNewColumnsResolved',
61
- actions: ['resolveMissing'],
62
- },
63
- ],
64
- CHOICE_ITEM: { target: 'action', actions: ['choseItem'] },
65
- },
66
- },
67
- action: {
68
- initial: 'actionChoice',
69
- states: {
70
- actionChoice: {
71
- on: { DELETE: '#resolveColumns.confirmationDelete', RENAME: 'rename' },
72
- },
73
- rename: {
74
- on: {
75
- CHOICE_NEW_ITEM: { target: '#resolveColumns.confirmationRename', actions: ['choseNewItem'] },
76
- },
77
- },
78
- },
79
- },
80
- confirmationDelete: {
81
- on: {
82
- CANCEL: 'action.actionChoice',
83
- CONFIRM: [
84
- { target: 'final', actions: ['delete'] },
85
- ],
86
- },
87
- },
88
- confirmationRename: {
89
- on: {
90
- CANCEL: 'action.actionChoice',
91
- CONFIRM: [
92
- { target: 'final', actions: ['rename'] },
93
- ],
94
- },
95
- },
96
- final: {
97
- entry: send({ type: 'NEXT' }),
98
- on: {
99
- NEXT: [
100
- {
101
- target: 'done',
102
- cond: 'isMissingColumnsResolved',
103
- actions: ['resolveRemaining'],
104
- },
105
- {
106
- target: 'table',
107
- },
108
- ],
109
- },
110
- },
111
- done: {},
112
- },
113
- },
114
- {
115
- guards: {
116
- isMissingColumnsResolved: ({ deletedColumns }) => !deletedColumns.length,
117
- isNewColumnsResolved: ({ addedColumns }) => !addedColumns.length,
118
- },
119
- actions: {
120
- choseItem: assign({
121
- missingItemIndex: (context, event) => (event.type === 'CHOICE_ITEM' ? event.itemIndex : 0),
122
- }),
123
-
124
- choseNewItem: assign({
125
- newItemIndex: (context, event) => (event.type === 'CHOICE_NEW_ITEM' ? event.itemIndex : 0),
126
- }),
127
-
128
- delete: assign({
129
- deleted: ({
130
- missingItemIndex,
131
- deleted,
132
- deletedColumns,
133
- }) => [...deleted, deletedColumns[missingItemIndex]],
134
- deletedColumns: ({
135
- missingItemIndex,
136
- deletedColumns,
137
- }) => deletedColumns.filter((_, index) => index !== missingItemIndex),
138
- }),
139
-
140
- rename: assign({
141
- renamed: ({
142
- missingItemIndex,
143
- newItemIndex,
144
- renamed,
145
- addedColumns,
146
- deletedColumns,
147
- }) => [
148
- ...renamed,
149
- { old: deletedColumns[missingItemIndex], new: addedColumns[newItemIndex] },
150
- ],
151
- deletedColumns: ({
152
- missingItemIndex,
153
- deletedColumns,
154
- }) => deletedColumns.filter((_, index) => index !== missingItemIndex),
155
- addedColumns: ({
156
- newItemIndex,
157
- addedColumns,
158
- }) => addedColumns.filter((_, index) => index !== newItemIndex),
159
- }),
160
-
161
- resolveRemaining: assign({
162
- created: ({
163
- addedColumns,
164
- created,
165
- }) => [...created, ...addedColumns],
166
- addedColumns: (context) => [],
167
- }),
168
-
169
- resolveMissing: assign({
170
- deleted: ({
171
- deletedColumns,
172
- deleted,
173
- }) => [...deleted, ...deletedColumns],
174
- deletedColumns: (context) => [],
175
- }),
176
- },
177
- }));
178
-
179
- export default createResolveColumnsMachine;
@@ -1,169 +0,0 @@
1
- import { assign, createMachine, send } from 'xstate';
2
- import { Named, RenamedObject } from 'cli/commands/migration/migrate';
3
-
4
- type Event =
5
- | { type: 'CHOICE_ITEM', itemIndex: number }
6
- | { type: 'DELETE' }
7
- | { type: 'RENAME' }
8
- | { type: 'CANCEL' }
9
- | { type: 'CONFIRM' }
10
- | { type: 'NEXT' }
11
- | { type: 'CHOICE_NEW_ITEM'; itemIndex: number };
12
-
13
- interface Context extends Props {
14
- missingItemIndex: number,
15
- newItemIndex: number,
16
- createdTables: Named[];
17
- renamedTables: RenamedObject<Named>[];
18
- deletedTables: Named[];
19
- }
20
-
21
- interface Props {
22
- missingTables: Named[],
23
- newTables: Named[],
24
- }
25
-
26
- const createResolveTablesMachine = (props: Props) => (
27
- createMachine<Context, Event>({
28
- id: 'resolveTables',
29
- initial: 'table',
30
- context: {
31
- ...props,
32
- missingItemIndex: 0,
33
- newItemIndex: 0,
34
- createdTables: [],
35
- renamedTables: [],
36
- deletedTables: [],
37
- },
38
- states: {
39
- table: {
40
- entry: send({ type: 'NEXT' }),
41
- on: {
42
- NEXT: [
43
- {
44
- target: 'done',
45
- cond: 'isMissingTablesResolved',
46
- actions: ['resolveRemaining'],
47
- },
48
- {
49
- target: 'done',
50
- cond: 'isNewTablesResolved',
51
- actions: ['resolveMissing'],
52
- },
53
- ],
54
- CHOICE_ITEM: { target: 'action', actions: ['choseItem'] },
55
- },
56
- },
57
- action: {
58
- initial: 'actionChoice',
59
- states: {
60
- actionChoice: {
61
- on: { DELETE: '#resolveTables.confirmationDelete', RENAME: 'rename' },
62
- },
63
- rename: {
64
- on: {
65
- CHOICE_NEW_ITEM: { target: '#resolveTables.confirmationRename', actions: ['choseNewItem'] },
66
- },
67
- },
68
- },
69
- },
70
- confirmationDelete: {
71
- on: {
72
- CANCEL: 'action.actionChoice',
73
- CONFIRM: [
74
- { target: 'final', actions: ['delete'] },
75
- ],
76
- },
77
- },
78
- confirmationRename: {
79
- on: {
80
- CANCEL: 'action.actionChoice',
81
- CONFIRM: [
82
- { target: 'final', actions: ['rename'] },
83
- ],
84
- },
85
- },
86
- final: {
87
- entry: send({ type: 'NEXT' }),
88
- on: {
89
- NEXT: [
90
- {
91
- target: 'done',
92
- cond: 'isMissingTablesResolved',
93
- actions: ['resolveRemaining'],
94
- },
95
- {
96
- target: 'table',
97
- },
98
- ],
99
- },
100
- },
101
- done: {},
102
- },
103
- },
104
- {
105
- guards: {
106
- isMissingTablesResolved: ({ missingTables }) => !missingTables.length,
107
- isNewTablesResolved: ({ newTables }) => !newTables.length,
108
- },
109
- actions: {
110
- choseItem: assign({
111
- missingItemIndex: (context, event) => (event.type === 'CHOICE_ITEM' ? event.itemIndex : 0),
112
- }),
113
-
114
- choseNewItem: assign({
115
- newItemIndex: (context, event) => (event.type === 'CHOICE_NEW_ITEM' ? event.itemIndex : 0),
116
- }),
117
-
118
- delete: assign({
119
- deletedTables: ({
120
- missingItemIndex,
121
- deletedTables,
122
- missingTables,
123
- }) => [...deletedTables, missingTables[missingItemIndex]],
124
- missingTables: ({
125
- missingItemIndex,
126
- missingTables,
127
- }) => missingTables.filter((_, index) => index !== missingItemIndex),
128
- }),
129
-
130
- rename: assign({
131
- renamedTables: ({
132
- missingItemIndex,
133
- newItemIndex,
134
- renamedTables,
135
- newTables,
136
- missingTables,
137
- }) => [
138
- ...renamedTables,
139
- { old: missingTables[missingItemIndex], new: newTables[newItemIndex] },
140
- ],
141
- missingTables: ({
142
- missingItemIndex,
143
- missingTables,
144
- }) => missingTables.filter((_, index) => index !== missingItemIndex),
145
- newTables: ({
146
- newItemIndex,
147
- newTables,
148
- }) => newTables.filter((_, index) => index !== newItemIndex),
149
- }),
150
-
151
- resolveRemaining: assign({
152
- createdTables: ({
153
- newTables,
154
- createdTables,
155
- }) => [...createdTables, ...newTables],
156
- newTables: (context) => [],
157
- }),
158
-
159
- resolveMissing: assign({
160
- deletedTables: ({
161
- missingTables,
162
- deletedTables,
163
- }) => [...deletedTables, ...missingTables],
164
- missingTables: (context) => [],
165
- }),
166
- },
167
- }));
168
-
169
- export default createResolveTablesMachine;
@@ -1,36 +0,0 @@
1
- import { Named, RenamedObject } from 'cli/commands/migration/migrate';
2
-
3
- interface ScalarDict {
4
- [key: string]: string
5
- }
6
-
7
- export default (
8
- data: {
9
- title: string;
10
- values: Named[] | RenamedObject<Named>[]
11
- }[],
12
- ): ScalarDict[] => {
13
- const array: ScalarDict[] = [];
14
-
15
- array.length = data.reduce((acc: number, { values }) => {
16
- if (acc < values.length) {
17
- return values.length;
18
- }
19
- return acc;
20
- },
21
- 0);
22
-
23
- array.fill({ '': '' });
24
-
25
- return array.map((_, i) => {
26
- const temp = {} as ScalarDict;
27
-
28
- data.forEach((item: any, ind: number) => {
29
- temp[data[ind].title] = item.values[i]?.old?.name
30
- ? `${item.values[i]?.old?.name} -> ${item.values[i]?.new?.name}`
31
- : item.values[i]?.name || '';
32
- });
33
-
34
- return temp as ScalarDict;
35
- });
36
- };
@@ -1,35 +0,0 @@
1
- export enum Action {
2
- RENAME = 'RENAME',
3
- DELETE = 'DELETE'
4
- }
5
-
6
- export enum Confirmation {
7
- CANCEL = 'CANCEL',
8
- CONFIRM = 'CONFIRM'
9
- }
10
-
11
- export const actions = [
12
- {
13
- key: Action.RENAME,
14
- label: 'Renamed',
15
- value: Action.RENAME,
16
- },
17
- {
18
- key: Action.DELETE,
19
- label: 'Deleted',
20
- value: Action.DELETE,
21
- },
22
- ];
23
-
24
- export const confirmations = [
25
- {
26
- key: Confirmation.CONFIRM,
27
- label: 'Yes',
28
- value: Confirmation.CONFIRM,
29
- },
30
- {
31
- key: Confirmation.CANCEL,
32
- label: 'No',
33
- value: Confirmation.CANCEL,
34
- },
35
- ];