@uidu/client 3.10.0 → 3.12.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,127 @@
1
+ import type { UiduClient } from "./client.js";
2
+ import { type GetGoalQuery, type GetGoalQueryVariables, type ListGoalsQueryVariables, type ListTimeframesQuery, type ListTimeframesQueryVariables, type UpdateGoalMutationVariables } from "./generated/index.js";
3
+ export type Goal = NonNullable<NonNullable<GetGoalQuery['currentWorkspace']>['goal']>;
4
+ export type Timeframe = NonNullable<NonNullable<NonNullable<NonNullable<ListTimeframesQuery['currentWorkspace']>['timeframes']>['edges']>[number]>['node'];
5
+ /** Every goal of the workspace (objectives and key results alike), newest first. Without `first`, all of them. */
6
+ export declare function listGoals(client: UiduClient, variables?: ListGoalsQueryVariables): Promise<{
7
+ __typename?: "Goal";
8
+ id: string;
9
+ name?: string | null;
10
+ description?: any | null;
11
+ kind?: import("./generated/index.js").GoalKind | null;
12
+ metricKind?: string | null;
13
+ status?: string | null;
14
+ currency?: string | null;
15
+ initialValue?: number | null;
16
+ currentValue?: number | null;
17
+ targetValue?: number | null;
18
+ progress?: number | null;
19
+ weight?: number | null;
20
+ updateFrequency?: string | null;
21
+ parentId?: string | null;
22
+ subgoalsCount?: number | null;
23
+ createdAt: any;
24
+ updatedAt: any;
25
+ timeframe?: {
26
+ __typename?: "Timeframe";
27
+ id: string;
28
+ name?: string | null;
29
+ startDate?: any | null;
30
+ endDate?: any | null;
31
+ } | null;
32
+ }[]>;
33
+ /** One goal with its key results (`subgoals`). */
34
+ export declare function getGoal(client: UiduClient, variables: GetGoalQueryVariables): Promise<Goal | null>;
35
+ export declare function listTimeframes(client: UiduClient, variables?: ListTimeframesQueryVariables): Promise<{
36
+ __typename?: "Timeframe";
37
+ id: string;
38
+ name?: string | null;
39
+ startDate?: any | null;
40
+ endDate?: any | null;
41
+ year?: number | null;
42
+ active?: boolean | null;
43
+ }[]>;
44
+ /**
45
+ * Authoring (Bearer / apiKey). Returns the payload, incl. `errors`.
46
+ * `initialValue` / `currentValue` / `targetValue` are stored x100: pass
47
+ * `toGoalRaw(value)`, never the number a person typed.
48
+ */
49
+ export declare function updateGoal(client: UiduClient, variables: UpdateGoalMutationVariables): Promise<{
50
+ __typename?: "UpdateGoalPayload";
51
+ goal?: {
52
+ __typename?: "Goal";
53
+ id: string;
54
+ name?: string | null;
55
+ description?: any | null;
56
+ kind?: import("./generated/index.js").GoalKind | null;
57
+ metricKind?: string | null;
58
+ status?: string | null;
59
+ currency?: string | null;
60
+ initialValue?: number | null;
61
+ currentValue?: number | null;
62
+ targetValue?: number | null;
63
+ progress?: number | null;
64
+ weight?: number | null;
65
+ updateFrequency?: string | null;
66
+ parentId?: string | null;
67
+ subgoalsCount?: number | null;
68
+ createdAt: any;
69
+ updatedAt: any;
70
+ timeframe?: {
71
+ __typename?: "Timeframe";
72
+ id: string;
73
+ name?: string | null;
74
+ startDate?: any | null;
75
+ endDate?: any | null;
76
+ } | null;
77
+ } | null;
78
+ errors: Array<{
79
+ __typename?: "Error";
80
+ key: string;
81
+ name: string;
82
+ type: string;
83
+ }>;
84
+ } | null>;
85
+ type GoalMetric = {
86
+ metricKind?: string | null;
87
+ };
88
+ /**
89
+ * A stored goal value (`initialValue`, `currentValue`, `targetValue`) in the
90
+ * unit a person typed: uidu keeps every one of them x100. For `percentage`
91
+ * that is percent points (45 = 45%), for `currency` whole units of
92
+ * `goal.currency`, for `checkbox` 1 or 0. `null` stays `null`.
93
+ */
94
+ export declare function goalValue(goal: GoalMetric, raw: number | null | undefined): number | null;
95
+ /** The inverse of `goalValue`, for `updateGoal`. */
96
+ export declare function toGoalRaw(value: number): number;
97
+ /**
98
+ * How far the goal is, 0 to 1 (above 1 when it overshoots). `goal.progress`
99
+ * itself is percent x100: 10000 is done.
100
+ */
101
+ export declare function goalProgress(goal: {
102
+ progress?: number | null;
103
+ }): number;
104
+ /**
105
+ * How much of the goal's timeframe has passed, 0 to 1, or `null` when it has
106
+ * none. A goal whose `goalProgress` is below this is behind schedule.
107
+ */
108
+ export declare function goalTimeElapsed(goal: {
109
+ timeframe?: {
110
+ startDate?: string | null;
111
+ endDate?: string | null;
112
+ } | null;
113
+ }, now?: Date): number | null;
114
+ /**
115
+ * Behind schedule: less done than time elapsed, by more than `tolerance`
116
+ * (0.1 = ten points). `false` for a goal with no timeframe or one already
117
+ * accomplished. The goal's own `status` (`off_track`, `needs_attention`) is
118
+ * its owner's judgement — show it next to this, don't replace one with the other.
119
+ */
120
+ export declare function isGoalBehind(goal: Parameters<typeof goalTimeElapsed>[0] & {
121
+ progress?: number | null;
122
+ status?: string | null;
123
+ }, { now, tolerance }?: {
124
+ now?: Date;
125
+ tolerance?: number;
126
+ }): boolean;
127
+ export {};
@@ -4,9 +4,11 @@ export type { UiduClientConfig, UiduErrorOptions } from "./types.js";
4
4
  export { paginate } from "./utils/paginate.js";
5
5
  export type { PaginateOptions } from "./utils/paginate.js";
6
6
  export { normalizeFieldValueContent, normalizeFieldValuesAttributes, } from "./utils/fieldValues.js";
7
- export { ListApplicationsDocument, ListBookingsDocument, ListCalendarsDocument, ListCalendarEventsDocument, ListCallsDocument, ListCampaignsDocument, ListEmailCampaignsDocument, ListCoursesDocument, ListDealsDocument, ListDonationCampaignsDocument, ListEmployeesDocument, ListEnrollmentsDocument, ListEventsDocument, ListFormsDocument, ListKbArticlesDocument, ListKbCollectionsDocument, ListLecturesDocument, ListPagesDocument, ListStoriesDocument, } from "./generated/index.js";
7
+ export { ListApplicationsDocument, ListBookingsDocument, ListCalendarsDocument, ListCalendarEventsDocument, ListCallsDocument, ListCampaignsDocument, ListEmailCampaignsDocument, ListCoursesDocument, ListDealsDocument, ListDonationCampaignsDocument, ListEmployeesDocument, ListEnrollmentsDocument, ListEventsDocument, ListFormsDocument, ListGoalsDocument, ListKbArticlesDocument, ListKbCollectionsDocument, ListLecturesDocument, ListPagesDocument, ListStoriesDocument, ListTimeframesDocument, } from "./generated/index.js";
8
8
  export { getPage, listPages, getTemplate, createProject, createPage, createPageBlock, createFieldValue, listProjects, } from "./cms.js";
9
9
  export type { Page, Template } from "./cms.js";
10
+ export { getSiteByDomain, getSite, getPageBySlug, listSitePages, getSingletonBlock, } from "./sites.js";
11
+ export type { Site, SiteModel, SiteFields, SiteBlock, SitePage, SitePageSummary, } from "./sites.js";
10
12
  export { createWorkspace, generateWorkspaceApiCredentials } from "./system.js";
11
13
  export { createSpace } from "./spaces.js";
12
14
  export { createTask } from "./tasks.js";
@@ -43,6 +45,8 @@ export { getCampaign, listCampaigns, listEmailCampaigns } from "./campaigns.js";
43
45
  export type { Campaign } from "./campaigns.js";
44
46
  export { getContact, listContacts, getDeal, listDeals } from "./contacts.js";
45
47
  export type { Contact, Deal } from "./contacts.js";
48
+ export { listGoals, getGoal, listTimeframes, updateGoal, goalValue, toGoalRaw, goalProgress, goalTimeElapsed, isGoalBehind, } from "./goals.js";
49
+ export type { Goal, Timeframe } from "./goals.js";
46
50
  export { getKbArticle, listKbArticles, getKbCollection, listKbCollections, } from "./kb.js";
47
51
  export type { KbArticle, KbCollection } from "./kb.js";
48
52
  export { listModels, getModel, listModelItems, getModelItem, createModel, updateModel, createField, updateField, deleteField, createFieldOption, updateFieldOption, deleteFieldOption, createModelItem, updateModelItem, deleteModelItem, updateFieldValue, deleteFieldValue, toFieldValuesAttributes, ensureModel, } from "./models.js";
@@ -0,0 +1,81 @@
1
+ import type { UiduClient } from "./client.js";
2
+ import { type PublishableStatus, type SiteFieldsFragment, type SiteModelFieldsFragment } from "./generated/index.js";
3
+ /**
4
+ * The new CMS: a Site, its page types (page-kind Models), its pages
5
+ * (ModelItems of those Models) and the blocks placed on each page (block-kind
6
+ * ModelItems, in order).
7
+ *
8
+ * This is not the legacy CMS in `cms.ts` (`getPage`/`listPages`, read
9
+ * through `currentWorkspace.project(id:)`): sites still deployed on a legacy
10
+ * Project keep calling those, unchanged. Use this module for Sites.
11
+ *
12
+ * Every read here is public: it works with a `publicToken` client, on the
13
+ * server (RSC) and in the browser.
14
+ */
15
+ export type Site = SiteFieldsFragment;
16
+ /** A Model as the site sees it: a page type, a block kind, a singleton. */
17
+ export type SiteModel = SiteModelFieldsFragment;
18
+ /** Field values keyed by field shortname: `{ title: '…', cover: {…} }`. */
19
+ export type SiteFields = Record<string, unknown>;
20
+ export type SiteBlock = {
21
+ /** The block ModelItem. */
22
+ id: string;
23
+ name: string | null;
24
+ /** The block kind (a block-kind Model). */
25
+ model: SiteModel;
26
+ fields: SiteFields;
27
+ position: number;
28
+ /** The placement (the child FieldValue) — what reordering/removing targets. */
29
+ placementId: string;
30
+ };
31
+ export type SitePageSummary = {
32
+ id: string;
33
+ name: string | null;
34
+ slug: string | null;
35
+ publishedAt: string | null;
36
+ status: PublishableStatus | null;
37
+ /** The page type (a page-kind Model), or the singleton Model. */
38
+ model: SiteModel;
39
+ };
40
+ export type SitePage = SitePageSummary & {
41
+ fields: SiteFields;
42
+ /** Ordered by position. */
43
+ blocks: SiteBlock[];
44
+ };
45
+ /** The Site served on `domain` (e.g. `www.acme.org`), or null. */
46
+ export declare function getSiteByDomain(client: UiduClient, variables: {
47
+ domain: string;
48
+ }): Promise<Site | null>;
49
+ /** A Site by its id — for previews, where there is no domain to go by. */
50
+ export declare function getSite(client: UiduClient, variables: {
51
+ id: string;
52
+ }): Promise<Site | null>;
53
+ /**
54
+ * A page of the Site by slug, with its field values and its ordered blocks.
55
+ * Only published pages unless `includeDrafts`.
56
+ */
57
+ export declare function getPageBySlug(client: UiduClient, variables: {
58
+ siteId: string;
59
+ slug: string;
60
+ includeDrafts?: boolean;
61
+ }): Promise<SitePage | null>;
62
+ /**
63
+ * The Site's pages, for navigation and sitemaps: published only unless
64
+ * `includeDrafts`, singletons (header, footer) left out.
65
+ *
66
+ * `pageType` keeps the pages of one page type, matched against its Model's
67
+ * id or name.
68
+ */
69
+ export declare function listSitePages(client: UiduClient, variables: {
70
+ siteId: string;
71
+ pageType?: string;
72
+ includeDrafts?: boolean;
73
+ }): Promise<SitePageSummary[]>;
74
+ /**
75
+ * A singleton of the Site — the header, the footer, the nav — by its Model's
76
+ * shortname, with its field values and blocks.
77
+ */
78
+ export declare function getSingletonBlock(client: UiduClient, variables: {
79
+ siteId: string;
80
+ shortname: string;
81
+ }): Promise<SitePage | null>;