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