weave-typescript 0.23.0 → 0.24.0
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.
- package/dist/weaveapi/organization/v1/organization.pb.d.ts +38 -0
- package/dist/weaveapi/organization/v1/organization.pb.js +252 -0
- package/dist/weaveapi/organization/v1/service.pb.d.ts +202 -0
- package/dist/weaveapi/organization/v1/service.pb.js +1112 -0
- package/dist/weavesql/weavedb/organization_sql.d.ts +121 -0
- package/dist/weavesql/weavedb/organization_sql.js +243 -0
- package/package.json +1 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { QueryArrayConfig, QueryArrayResult } from "pg";
|
|
2
|
+
interface Client {
|
|
3
|
+
query: (config: QueryArrayConfig) => Promise<QueryArrayResult>;
|
|
4
|
+
}
|
|
5
|
+
export declare const createOrganizationQuery = "-- name: CreateOrganization :one\nINSERT INTO weave.organizations (\n slug,\n name,\n description,\n primary_color,\n timezone,\n location\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6\n)\nON CONFLICT (slug) DO NOTHING\nRETURNING\n id,\n slug,\n name,\n description,\n primary_color,\n (logo IS NOT NULL) AS has_logo,\n timezone,\n location,\n created_at,\n updated_at";
|
|
6
|
+
export interface CreateOrganizationArgs {
|
|
7
|
+
slug: string;
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
primaryColor: string;
|
|
11
|
+
timezone: string;
|
|
12
|
+
location: string;
|
|
13
|
+
}
|
|
14
|
+
export interface CreateOrganizationRow {
|
|
15
|
+
id: string;
|
|
16
|
+
slug: string;
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
primaryColor: string;
|
|
20
|
+
hasLogo: string | null;
|
|
21
|
+
timezone: string;
|
|
22
|
+
location: string;
|
|
23
|
+
createdAt: Date;
|
|
24
|
+
updatedAt: Date;
|
|
25
|
+
}
|
|
26
|
+
export declare function createOrganization(client: Client, args: CreateOrganizationArgs): Promise<CreateOrganizationRow | null>;
|
|
27
|
+
export declare const getOrganizationBySlugQuery = "-- name: GetOrganizationBySlug :one\nSELECT\n id,\n slug,\n name,\n description,\n primary_color,\n (logo IS NOT NULL) AS has_logo,\n timezone,\n location,\n created_at,\n updated_at\nFROM weave.organizations\nWHERE slug = $1";
|
|
28
|
+
export interface GetOrganizationBySlugArgs {
|
|
29
|
+
slug: string;
|
|
30
|
+
}
|
|
31
|
+
export interface GetOrganizationBySlugRow {
|
|
32
|
+
id: string;
|
|
33
|
+
slug: string;
|
|
34
|
+
name: string;
|
|
35
|
+
description: string;
|
|
36
|
+
primaryColor: string;
|
|
37
|
+
hasLogo: string | null;
|
|
38
|
+
timezone: string;
|
|
39
|
+
location: string;
|
|
40
|
+
createdAt: Date;
|
|
41
|
+
updatedAt: Date;
|
|
42
|
+
}
|
|
43
|
+
export declare function getOrganizationBySlug(client: Client, args: GetOrganizationBySlugArgs): Promise<GetOrganizationBySlugRow | null>;
|
|
44
|
+
export declare const getOrganizationByIDQuery = "-- name: GetOrganizationByID :one\nSELECT\n id,\n slug,\n name,\n description,\n primary_color,\n (logo IS NOT NULL) AS has_logo,\n timezone,\n location,\n created_at,\n updated_at\nFROM weave.organizations\nWHERE id = $1";
|
|
45
|
+
export interface GetOrganizationByIDArgs {
|
|
46
|
+
id: string;
|
|
47
|
+
}
|
|
48
|
+
export interface GetOrganizationByIDRow {
|
|
49
|
+
id: string;
|
|
50
|
+
slug: string;
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
primaryColor: string;
|
|
54
|
+
hasLogo: string | null;
|
|
55
|
+
timezone: string;
|
|
56
|
+
location: string;
|
|
57
|
+
createdAt: Date;
|
|
58
|
+
updatedAt: Date;
|
|
59
|
+
}
|
|
60
|
+
export declare function getOrganizationByID(client: Client, args: GetOrganizationByIDArgs): Promise<GetOrganizationByIDRow | null>;
|
|
61
|
+
export declare const listOrganizationsQuery = "-- name: ListOrganizations :many\nSELECT\n id,\n slug,\n name,\n description,\n primary_color,\n (logo IS NOT NULL) AS has_logo,\n timezone,\n location,\n created_at,\n updated_at\nFROM weave.organizations\nORDER BY created_at DESC";
|
|
62
|
+
export interface ListOrganizationsRow {
|
|
63
|
+
id: string;
|
|
64
|
+
slug: string;
|
|
65
|
+
name: string;
|
|
66
|
+
description: string;
|
|
67
|
+
primaryColor: string;
|
|
68
|
+
hasLogo: string | null;
|
|
69
|
+
timezone: string;
|
|
70
|
+
location: string;
|
|
71
|
+
createdAt: Date;
|
|
72
|
+
updatedAt: Date;
|
|
73
|
+
}
|
|
74
|
+
export declare function listOrganizations(client: Client): Promise<ListOrganizationsRow[]>;
|
|
75
|
+
export declare const updateOrganizationQuery = "-- name: UpdateOrganization :one\nUPDATE weave.organizations\nSET\n slug = COALESCE($1, slug),\n name = COALESCE($2, name),\n description = COALESCE($3, description),\n primary_color = COALESCE($4, primary_color),\n timezone = COALESCE($5, timezone),\n location = COALESCE($6, location)\nWHERE id = $7\nRETURNING\n id,\n slug,\n name,\n description,\n primary_color,\n (logo IS NOT NULL) AS has_logo,\n timezone,\n location,\n created_at,\n updated_at";
|
|
76
|
+
export interface UpdateOrganizationArgs {
|
|
77
|
+
slug: string | null;
|
|
78
|
+
name: string | null;
|
|
79
|
+
description: string | null;
|
|
80
|
+
primaryColor: string | null;
|
|
81
|
+
timezone: string | null;
|
|
82
|
+
location: string | null;
|
|
83
|
+
id: string;
|
|
84
|
+
}
|
|
85
|
+
export interface UpdateOrganizationRow {
|
|
86
|
+
id: string;
|
|
87
|
+
slug: string;
|
|
88
|
+
name: string;
|
|
89
|
+
description: string;
|
|
90
|
+
primaryColor: string;
|
|
91
|
+
hasLogo: string | null;
|
|
92
|
+
timezone: string;
|
|
93
|
+
location: string;
|
|
94
|
+
createdAt: Date;
|
|
95
|
+
updatedAt: Date;
|
|
96
|
+
}
|
|
97
|
+
export declare function updateOrganization(client: Client, args: UpdateOrganizationArgs): Promise<UpdateOrganizationRow | null>;
|
|
98
|
+
export declare const deleteOrganizationQuery = "-- name: DeleteOrganization :execrows\nDELETE FROM weave.organizations\nWHERE id = $1";
|
|
99
|
+
export interface DeleteOrganizationArgs {
|
|
100
|
+
id: string;
|
|
101
|
+
}
|
|
102
|
+
export declare const getOrganizationLogoQuery = "-- name: GetOrganizationLogo :one\nSELECT logo, logo_content_type\nFROM weave.organizations\nWHERE slug = $1";
|
|
103
|
+
export interface GetOrganizationLogoArgs {
|
|
104
|
+
slug: string;
|
|
105
|
+
}
|
|
106
|
+
export interface GetOrganizationLogoRow {
|
|
107
|
+
logo: Buffer | null;
|
|
108
|
+
logoContentType: string | null;
|
|
109
|
+
}
|
|
110
|
+
export declare function getOrganizationLogo(client: Client, args: GetOrganizationLogoArgs): Promise<GetOrganizationLogoRow | null>;
|
|
111
|
+
export declare const setOrganizationLogoQuery = "-- name: SetOrganizationLogo :execrows\nUPDATE weave.organizations\nSET logo = $1, logo_content_type = $2\nWHERE slug = $3";
|
|
112
|
+
export interface SetOrganizationLogoArgs {
|
|
113
|
+
logo: Buffer | null;
|
|
114
|
+
logoContentType: string | null;
|
|
115
|
+
slug: string;
|
|
116
|
+
}
|
|
117
|
+
export declare const clearOrganizationLogoQuery = "-- name: ClearOrganizationLogo :execrows\nUPDATE weave.organizations\nSET logo = NULL, logo_content_type = NULL\nWHERE slug = $1";
|
|
118
|
+
export interface ClearOrganizationLogoArgs {
|
|
119
|
+
slug: string;
|
|
120
|
+
}
|
|
121
|
+
export {};
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clearOrganizationLogoQuery = exports.setOrganizationLogoQuery = exports.getOrganizationLogoQuery = exports.deleteOrganizationQuery = exports.updateOrganizationQuery = exports.listOrganizationsQuery = exports.getOrganizationByIDQuery = exports.getOrganizationBySlugQuery = exports.createOrganizationQuery = void 0;
|
|
4
|
+
exports.createOrganization = createOrganization;
|
|
5
|
+
exports.getOrganizationBySlug = getOrganizationBySlug;
|
|
6
|
+
exports.getOrganizationByID = getOrganizationByID;
|
|
7
|
+
exports.listOrganizations = listOrganizations;
|
|
8
|
+
exports.updateOrganization = updateOrganization;
|
|
9
|
+
exports.getOrganizationLogo = getOrganizationLogo;
|
|
10
|
+
exports.createOrganizationQuery = `-- name: CreateOrganization :one
|
|
11
|
+
INSERT INTO weave.organizations (
|
|
12
|
+
slug,
|
|
13
|
+
name,
|
|
14
|
+
description,
|
|
15
|
+
primary_color,
|
|
16
|
+
timezone,
|
|
17
|
+
location
|
|
18
|
+
) VALUES (
|
|
19
|
+
$1,
|
|
20
|
+
$2,
|
|
21
|
+
$3,
|
|
22
|
+
$4,
|
|
23
|
+
$5,
|
|
24
|
+
$6
|
|
25
|
+
)
|
|
26
|
+
ON CONFLICT (slug) DO NOTHING
|
|
27
|
+
RETURNING
|
|
28
|
+
id,
|
|
29
|
+
slug,
|
|
30
|
+
name,
|
|
31
|
+
description,
|
|
32
|
+
primary_color,
|
|
33
|
+
(logo IS NOT NULL) AS has_logo,
|
|
34
|
+
timezone,
|
|
35
|
+
location,
|
|
36
|
+
created_at,
|
|
37
|
+
updated_at`;
|
|
38
|
+
async function createOrganization(client, args) {
|
|
39
|
+
const result = await client.query({
|
|
40
|
+
text: exports.createOrganizationQuery,
|
|
41
|
+
values: [args.slug, args.name, args.description, args.primaryColor, args.timezone, args.location],
|
|
42
|
+
rowMode: "array"
|
|
43
|
+
});
|
|
44
|
+
if (result.rows.length !== 1) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const row = result.rows[0];
|
|
48
|
+
return {
|
|
49
|
+
id: row[0],
|
|
50
|
+
slug: row[1],
|
|
51
|
+
name: row[2],
|
|
52
|
+
description: row[3],
|
|
53
|
+
primaryColor: row[4],
|
|
54
|
+
hasLogo: row[5],
|
|
55
|
+
timezone: row[6],
|
|
56
|
+
location: row[7],
|
|
57
|
+
createdAt: row[8],
|
|
58
|
+
updatedAt: row[9]
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
exports.getOrganizationBySlugQuery = `-- name: GetOrganizationBySlug :one
|
|
62
|
+
SELECT
|
|
63
|
+
id,
|
|
64
|
+
slug,
|
|
65
|
+
name,
|
|
66
|
+
description,
|
|
67
|
+
primary_color,
|
|
68
|
+
(logo IS NOT NULL) AS has_logo,
|
|
69
|
+
timezone,
|
|
70
|
+
location,
|
|
71
|
+
created_at,
|
|
72
|
+
updated_at
|
|
73
|
+
FROM weave.organizations
|
|
74
|
+
WHERE slug = $1`;
|
|
75
|
+
async function getOrganizationBySlug(client, args) {
|
|
76
|
+
const result = await client.query({
|
|
77
|
+
text: exports.getOrganizationBySlugQuery,
|
|
78
|
+
values: [args.slug],
|
|
79
|
+
rowMode: "array"
|
|
80
|
+
});
|
|
81
|
+
if (result.rows.length !== 1) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
const row = result.rows[0];
|
|
85
|
+
return {
|
|
86
|
+
id: row[0],
|
|
87
|
+
slug: row[1],
|
|
88
|
+
name: row[2],
|
|
89
|
+
description: row[3],
|
|
90
|
+
primaryColor: row[4],
|
|
91
|
+
hasLogo: row[5],
|
|
92
|
+
timezone: row[6],
|
|
93
|
+
location: row[7],
|
|
94
|
+
createdAt: row[8],
|
|
95
|
+
updatedAt: row[9]
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
exports.getOrganizationByIDQuery = `-- name: GetOrganizationByID :one
|
|
99
|
+
SELECT
|
|
100
|
+
id,
|
|
101
|
+
slug,
|
|
102
|
+
name,
|
|
103
|
+
description,
|
|
104
|
+
primary_color,
|
|
105
|
+
(logo IS NOT NULL) AS has_logo,
|
|
106
|
+
timezone,
|
|
107
|
+
location,
|
|
108
|
+
created_at,
|
|
109
|
+
updated_at
|
|
110
|
+
FROM weave.organizations
|
|
111
|
+
WHERE id = $1`;
|
|
112
|
+
async function getOrganizationByID(client, args) {
|
|
113
|
+
const result = await client.query({
|
|
114
|
+
text: exports.getOrganizationByIDQuery,
|
|
115
|
+
values: [args.id],
|
|
116
|
+
rowMode: "array"
|
|
117
|
+
});
|
|
118
|
+
if (result.rows.length !== 1) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
const row = result.rows[0];
|
|
122
|
+
return {
|
|
123
|
+
id: row[0],
|
|
124
|
+
slug: row[1],
|
|
125
|
+
name: row[2],
|
|
126
|
+
description: row[3],
|
|
127
|
+
primaryColor: row[4],
|
|
128
|
+
hasLogo: row[5],
|
|
129
|
+
timezone: row[6],
|
|
130
|
+
location: row[7],
|
|
131
|
+
createdAt: row[8],
|
|
132
|
+
updatedAt: row[9]
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
exports.listOrganizationsQuery = `-- name: ListOrganizations :many
|
|
136
|
+
SELECT
|
|
137
|
+
id,
|
|
138
|
+
slug,
|
|
139
|
+
name,
|
|
140
|
+
description,
|
|
141
|
+
primary_color,
|
|
142
|
+
(logo IS NOT NULL) AS has_logo,
|
|
143
|
+
timezone,
|
|
144
|
+
location,
|
|
145
|
+
created_at,
|
|
146
|
+
updated_at
|
|
147
|
+
FROM weave.organizations
|
|
148
|
+
ORDER BY created_at DESC`;
|
|
149
|
+
async function listOrganizations(client) {
|
|
150
|
+
const result = await client.query({
|
|
151
|
+
text: exports.listOrganizationsQuery,
|
|
152
|
+
values: [],
|
|
153
|
+
rowMode: "array"
|
|
154
|
+
});
|
|
155
|
+
return result.rows.map(row => {
|
|
156
|
+
return {
|
|
157
|
+
id: row[0],
|
|
158
|
+
slug: row[1],
|
|
159
|
+
name: row[2],
|
|
160
|
+
description: row[3],
|
|
161
|
+
primaryColor: row[4],
|
|
162
|
+
hasLogo: row[5],
|
|
163
|
+
timezone: row[6],
|
|
164
|
+
location: row[7],
|
|
165
|
+
createdAt: row[8],
|
|
166
|
+
updatedAt: row[9]
|
|
167
|
+
};
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
exports.updateOrganizationQuery = `-- name: UpdateOrganization :one
|
|
171
|
+
UPDATE weave.organizations
|
|
172
|
+
SET
|
|
173
|
+
slug = COALESCE($1, slug),
|
|
174
|
+
name = COALESCE($2, name),
|
|
175
|
+
description = COALESCE($3, description),
|
|
176
|
+
primary_color = COALESCE($4, primary_color),
|
|
177
|
+
timezone = COALESCE($5, timezone),
|
|
178
|
+
location = COALESCE($6, location)
|
|
179
|
+
WHERE id = $7
|
|
180
|
+
RETURNING
|
|
181
|
+
id,
|
|
182
|
+
slug,
|
|
183
|
+
name,
|
|
184
|
+
description,
|
|
185
|
+
primary_color,
|
|
186
|
+
(logo IS NOT NULL) AS has_logo,
|
|
187
|
+
timezone,
|
|
188
|
+
location,
|
|
189
|
+
created_at,
|
|
190
|
+
updated_at`;
|
|
191
|
+
async function updateOrganization(client, args) {
|
|
192
|
+
const result = await client.query({
|
|
193
|
+
text: exports.updateOrganizationQuery,
|
|
194
|
+
values: [args.slug, args.name, args.description, args.primaryColor, args.timezone, args.location, args.id],
|
|
195
|
+
rowMode: "array"
|
|
196
|
+
});
|
|
197
|
+
if (result.rows.length !== 1) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
const row = result.rows[0];
|
|
201
|
+
return {
|
|
202
|
+
id: row[0],
|
|
203
|
+
slug: row[1],
|
|
204
|
+
name: row[2],
|
|
205
|
+
description: row[3],
|
|
206
|
+
primaryColor: row[4],
|
|
207
|
+
hasLogo: row[5],
|
|
208
|
+
timezone: row[6],
|
|
209
|
+
location: row[7],
|
|
210
|
+
createdAt: row[8],
|
|
211
|
+
updatedAt: row[9]
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
exports.deleteOrganizationQuery = `-- name: DeleteOrganization :execrows
|
|
215
|
+
DELETE FROM weave.organizations
|
|
216
|
+
WHERE id = $1`;
|
|
217
|
+
exports.getOrganizationLogoQuery = `-- name: GetOrganizationLogo :one
|
|
218
|
+
SELECT logo, logo_content_type
|
|
219
|
+
FROM weave.organizations
|
|
220
|
+
WHERE slug = $1`;
|
|
221
|
+
async function getOrganizationLogo(client, args) {
|
|
222
|
+
const result = await client.query({
|
|
223
|
+
text: exports.getOrganizationLogoQuery,
|
|
224
|
+
values: [args.slug],
|
|
225
|
+
rowMode: "array"
|
|
226
|
+
});
|
|
227
|
+
if (result.rows.length !== 1) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
const row = result.rows[0];
|
|
231
|
+
return {
|
|
232
|
+
logo: row[0],
|
|
233
|
+
logoContentType: row[1]
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
exports.setOrganizationLogoQuery = `-- name: SetOrganizationLogo :execrows
|
|
237
|
+
UPDATE weave.organizations
|
|
238
|
+
SET logo = $1, logo_content_type = $2
|
|
239
|
+
WHERE slug = $3`;
|
|
240
|
+
exports.clearOrganizationLogoQuery = `-- name: ClearOrganizationLogo :execrows
|
|
241
|
+
UPDATE weave.organizations
|
|
242
|
+
SET logo = NULL, logo_content_type = NULL
|
|
243
|
+
WHERE slug = $1`;
|