-
Notifications
You must be signed in to change notification settings - Fork 280
/
create-schema-node.ts
42 lines (37 loc) · 1.01 KB
/
create-schema-node.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { freeze } from '../util/object-utils.js'
import { IdentifierNode } from './identifier-node.js'
import { OperationNode } from './operation-node.js'
export type CreateSchemaNodeModifier = 'IfNotExists'
export type CreateSchemaNodeParams = Omit<
Partial<CreateSchemaNode>,
'kind' | 'schema'
>
export interface CreateSchemaNode extends OperationNode {
readonly kind: 'CreateSchemaNode'
readonly schema: IdentifierNode
readonly modifier?: CreateSchemaNodeModifier
}
/**
* @internal
*/
export const CreateSchemaNode = freeze({
is(node: OperationNode): node is CreateSchemaNode {
return node.kind === 'CreateSchemaNode'
},
create(schema: string, params?: CreateSchemaNodeParams): CreateSchemaNode {
return freeze({
kind: 'CreateSchemaNode',
schema: IdentifierNode.create(schema),
...params,
})
},
cloneWith(
createSchema: CreateSchemaNode,
params: CreateSchemaNodeParams
): CreateSchemaNode {
return freeze({
...createSchema,
...params,
})
},
})