@uidu/client 3.6.0 → 3.7.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @uidu/client
2
2
 
3
+ ## 3.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 1149d0b: `codegen.ts` builds its endpoint from `UIDU_HOST` (default `uidu.org`) instead
8
+ of hardcoding the domain, so a workspace that only exists on staging can be
9
+ introspected — and `UIDU_WORKSPACE=demo` no longer silently resolves to
10
+ `demo.uidu.org`, which 404s.
11
+
12
+ ## 3.7.0
13
+
14
+ ### Minor Changes
15
+
16
+ - 7756c71: Add `listProjects` and `listChannels`, and expose them as the `projects` and
17
+ `channel` CLI resources' `list` verb. A caller that needs a project id for
18
+ `getPage`, or a help-center channel id, can now find one instead of being told
19
+ it — the demo used to carry a production workspace's GlobalIDs for both.
20
+
3
21
  ## 3.6.0
4
22
 
5
23
  ### Minor Changes
package/codegen.ts CHANGED
@@ -19,17 +19,43 @@ loadEnvFile('.env');
19
19
 
20
20
  const workspace = process.env.UIDU_WORKSPACE ?? 'uidu';
21
21
  const publicToken = process.env.UIDU_PUBLIC_TOKEN ?? '';
22
+ // `.uidu.org` used to be baked in here, which meant a workspace that only
23
+ // exists on staging could not be introspected at all — and, worse, that
24
+ // `UIDU_WORKSPACE=demo` silently resolved to `demo.uidu.org`, which 404s.
25
+ const host = process.env.UIDU_HOST ?? 'uidu.org';
22
26
  const endpoint =
23
- process.env.UIDU_GRAPHQL_ENDPOINT ?? `https://${workspace}.uidu.org/graphql`;
27
+ process.env.UIDU_GRAPHQL_ENDPOINT ?? `https://${workspace}.${host}/graphql`;
28
+
29
+ /**
30
+ * The SDL from a `uidu` checkout beside this one, when there is one.
31
+ *
32
+ * Reading the schema over HTTPS is not available everywhere this runs: the
33
+ * cloud sandbox the SDK sync routine lives in is denied at the proxy (403 on
34
+ * CONNECT to uidu.uidu.org), and no token fixes that — it never reaches the
35
+ * TLS handshake. It clones the organisation's repos instead, and
36
+ * `app/graphql/schema.graphql` is committed there, regenerated by
37
+ * `rake schema:dump`. Same source the live endpoint would serve, one deploy
38
+ * earlier at worst.
39
+ *
40
+ * `UIDU_SCHEMA` overrides the path; delete or move the checkout to force the
41
+ * endpoint.
42
+ */
43
+ const localSchema = [
44
+ process.env.UIDU_SCHEMA,
45
+ resolve(process.cwd(), '../../../uidu/app/graphql/schema.graphql'),
46
+ resolve(process.cwd(), '../../uidu/app/graphql/schema.graphql'),
47
+ ].find((path) => path && existsSync(path));
24
48
 
25
49
  const config: CodegenConfig = {
26
- schema: [
27
- {
28
- [endpoint]: {
29
- headers: publicToken ? { 'X-Uidu-Public-Token': publicToken } : {},
30
- },
31
- },
32
- ],
50
+ schema: localSchema
51
+ ? [localSchema]
52
+ : [
53
+ {
54
+ [endpoint]: {
55
+ headers: publicToken ? { 'X-Uidu-Public-Token': publicToken } : {},
56
+ },
57
+ },
58
+ ],
33
59
  documents: ['src/**/*.graphql'],
34
60
  generates: {
35
61
  'src/generated/index.ts': {
@@ -1,5 +1,5 @@
1
1
  import type { UiduClient } from "./client.js";
2
- import { type CreateFieldValueMutationVariables, type CreatePageBlockMutationVariables, type CreatePageMutationVariables, type CreateProjectMutationVariables, type GetPageQuery, type GetPageQueryVariables, type GetTemplateQuery, type GetTemplateQueryVariables, type ListPagesQueryVariables } from "./generated/index.js";
2
+ import { type CreateFieldValueMutationVariables, type CreatePageBlockMutationVariables, type CreatePageMutationVariables, type CreateProjectMutationVariables, type GetPageQuery, type GetPageQueryVariables, type GetTemplateQuery, type GetTemplateQueryVariables, type ListProjectsQueryVariables, type ListPagesQueryVariables } from "./generated/index.js";
3
3
  export type Page = NonNullable<NonNullable<NonNullable<GetPageQuery['currentWorkspace']>['project']>['page']>;
4
4
  export type Template = NonNullable<NonNullable<NonNullable<GetTemplateQuery['currentWorkspace']>['project']>['template']>;
5
5
  export declare function getPage(client: UiduClient, variables: GetPageQueryVariables): Promise<Page | null>;
@@ -73,3 +73,10 @@ export declare function createFieldValue(client: UiduClient, variables: CreateFi
73
73
  type: string;
74
74
  }>;
75
75
  } | null>;
76
+ /** The workspace's CMS projects. A page lives in one, and `getPage` needs its id. */
77
+ export declare function listProjects(client: UiduClient, variables?: ListProjectsQueryVariables): Promise<{
78
+ __typename?: "Project";
79
+ id: string;
80
+ name?: string | null;
81
+ slug?: string | null;
82
+ }[]>;