@processfocus/plugin-google-drive 0.1.0-next.2 → 0.1.0-next.4

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/README.md CHANGED
@@ -1,161 +1,65 @@
1
1
  # @processfocus/plugin-google-drive
2
2
 
3
- Google Drive file picker plugin for Process Focus forms.
3
+ Adds a Google Drive file picker to Process Focus forms. Forms can keep selected
4
+ file metadata or save a PDF copy to a Document Store.
4
5
 
5
- ## Environment Variables
6
+ ## Setup
6
7
 
7
- The server-side form walker reads these public Google Picker values from the
8
- runtime environment and sends them to the form renderer through field
9
- `pluginData`. They are intentionally client-visible Picker configuration, not
10
- secret credentials. Next.js does not embed them at build time.
8
+ Enable the Google Drive and Google Picker APIs in Google Cloud. Configure the
9
+ OAuth client for your Dashboard origin and restrict the browser API key to that
10
+ origin and the Picker API.
11
11
 
12
- | Variable | Description |
13
- |---|---|
14
- | `GOOGLE_DRIVE_PICKER_CLIENT_ID` | Google OAuth 2.0 client ID (public) |
15
- | `GOOGLE_DRIVE_PICKER_APP_ID` | Google Cloud project number / app ID (public) |
16
- | `GOOGLE_DRIVE_PICKER_DEVELOPER_KEY` | Browser-restricted API key for Google Picker (public) |
12
+ | Runtime setting | Value |
13
+ | --- | --- |
14
+ | `GOOGLE_DRIVE_PICKER_CLIENT_ID` | Public OAuth client ID |
15
+ | `GOOGLE_DRIVE_PICKER_APP_ID` | Google Cloud project number |
16
+ | `GOOGLE_DRIVE_PICKER_DEVELOPER_KEY` | Browser-restricted Picker API key |
17
17
 
18
- Environment configuration changes require a redeploy so the runtime receives
19
- the new values.
18
+ These settings are browser-visible. Missing configuration leaves the picker
19
+ unavailable. Redeploy after changing hosted configuration.
20
20
 
21
- Google Cloud must have the Google Drive API and Google Picker API enabled. The
22
- OAuth client must allow the Dashboard origin. Restrict the developer key to the
23
- Dashboard's browser origins and the Google Picker API. The picker requests only
24
- `https://www.googleapis.com/auth/drive.file`.
21
+ ## Use in an organisation
25
22
 
26
- ## Usage
27
-
28
- ### Process model
29
-
30
- ```typescript
23
+ ```ts
31
24
  import {
32
25
  GoogleDrive,
26
+ GoogleDriveConfiguration,
33
27
  GoogleDriveField,
34
- parseGoogleDriveGeneratedPdf,
35
28
  } from "@processfocus/plugin-google-drive"
36
29
 
37
30
  new GoogleDrive(org, "google-drive")
31
+ export const Configuration = { version: 1, groups: [GoogleDriveConfiguration] }
38
32
 
39
- // In a form schema
40
- const schema = {
41
- document: GoogleDriveField({
42
- label: "Tramping plan",
43
- generatePdf: pdfStore,
44
- }),
33
+ const fields = {
34
+ document: GoogleDriveField({ label: "Document", generatePdf: pdfStore }),
45
35
  }
46
-
47
- // In a later process consumer
48
- const document = parseGoogleDriveGeneratedPdf(state.document)
49
36
  ```
50
37
 
51
- This is the canonical pattern for process documents selected from Google Drive.
52
- The browser exports the selected file as PDF with the user's in-memory OAuth
53
- token, requests a short-lived signed upload URL, and uploads directly to the
54
- configured `DocumentStore` before the form is submitted. The form value contains
55
- only the stored PDF's non-empty `{ fileId, filename }` reference. Process models
56
- use `parseGoogleDriveGeneratedPdf` to validate and consume that reference
57
- directly; no additional system step is needed.
58
-
59
- Without `generatePdf`, use `parseGoogleDriveValue` to validate and read the
60
- selected file metadata in a later step.
61
-
62
- ### Organisation artifact registration
38
+ Here `org` is the organisation and `pdfStore` is its Document Store. The
39
+ `GoogleDrive` construct packages the renderer and stylesheet with the organisation.
63
40
 
64
- `new GoogleDrive(org, "google-drive")` declares the browser renderer and its
65
- build-time Tailwind stylesheet as organisation artifact inputs. `pfcli build`
66
- emits both as content-addressed, integrity-checked files. Dashboard and public
67
- routes consume those emitted files without resolving this package from the
68
- host runtime.
41
+ With `generatePdf`, the form saves a PDF and returns a stored-file reference.
42
+ Use `parseGoogleDriveGeneratedPdf` to read it in later process steps. PDF sources
43
+ can be Google Docs, Sheets, Slides, Drawings or existing PDFs.
69
44
 
70
- Importing `GoogleDriveField` registers the walker beside the organisation's
71
- form model, so bundled form projection uses the registry in the organisation
72
- bundle realm. Local and AWS hosts do not import this plugin.
45
+ Omit `generatePdf` to retain selected-file metadata instead, read with
46
+ `parseGoogleDriveValue`. Drive access uses the person's browser consent with the
47
+ `drive.file` scope; OAuth tokens are not part of the saved form value.
73
48
 
74
- ### Low-level frontend registration
75
-
76
- The Dashboard's organisation plugin composition activates the browser entrypoint
77
- once before any form renders and injects its host capabilities:
78
-
79
- ```typescript
80
- import { organisationFrontendPlugin } from "@processfocus/plugin-google-drive/register-client"
81
-
82
- organisationFrontendPlugin.activate(host)
83
- ```
49
+ ## Shared browser forms
84
50
 
85
- This registers the React renderer without importing Dashboard or form-registry
86
- source. React and the frontend plugin host contract remain host-provided. The
87
- picker is code-split and only loaded when a Google Drive field is rendered.
88
- Schema walking remains a separate server entrypoint.
89
-
90
- The Dashboard wraps authenticated form trees in its organisation plugin host
91
- implementation so `generatePdf` fields can request signed document-store
92
- upload URLs through authenticated GraphQL.
93
-
94
- ### Server-only (walker only)
95
-
96
- If you only need schema walking without React (e.g. server-side):
97
-
98
- ```typescript
99
- import { registerGoogleDriveWalkerPlugin } from "@processfocus/plugin-google-drive/register-walker"
100
-
101
- registerGoogleDriveWalkerPlugin()
102
- ```
51
+ Import fields and parsers from `@processfocus/plugin-google-drive/field` in
52
+ browser-shared form modules. Keep the `GoogleDrive` construct on the server.
53
+ Supply public Picker settings through the Form's
54
+ `browser.resolvePluginConfiguration`, keyed by the submitted field path, using
55
+ `readGoogleDrivePickerConfiguration`.
103
56
 
104
57
  ## Content Security Policy
105
58
 
106
- The plugin loads two external Google scripts at runtime. Your CSP must
107
- allow at minimum:
59
+ Self-managed frontends must allow the Google scripts, frames and requests:
108
60
 
109
- ```
61
+ ```text
110
62
  script-src https://accounts.google.com https://apis.google.com;
111
63
  frame-src https://accounts.google.com https://docs.google.com https://drive.google.com;
112
64
  connect-src https://accounts.google.com https://www.googleapis.com https://docs.google.com https://*.googleusercontent.com;
113
65
  ```
114
-
115
- Subresource Integrity (SRI) hashes are not used because both Google
116
- endpoints serve version-less bundles whose content changes without notice.
117
-
118
- ## How it works
119
-
120
- 1. `GoogleDriveField` creates an Effect Schema string field annotated with
121
- `FormGoogleDriveInput`.
122
- 2. The walker plugin recognises this annotation and emits a `PluginField`
123
- node. Public Picker configuration is read from the server runtime and
124
- sent to the renderer as field `pluginData`.
125
- 3. The renderer plugin lazy-loads `GoogleDrivePicker`, which handles its
126
- own OAuth consent via Google Identity Services (the app's login token
127
- only has profile/email scopes, not Drive). Scope is
128
- `https://www.googleapis.com/auth/drive.file`. GIS is hinted with the
129
- signed-in email and does not force consent after the user has granted
130
- Drive access.
131
- 4. Without `generatePdf`, the selected file metadata is stored as a JSON
132
- string in the form field.
133
- 5. With `generatePdf`, the browser uses the in-memory token to export the first
134
- tab of a Google Doc through the Docs download endpoint, falling back to the
135
- Drive export endpoint if needed. Sheets, Slides, and Drawings use Drive
136
- export, while existing PDFs use the Drive media-download endpoint.
137
- 6. The browser requests a short-lived, step-authorized upload URL and uploads
138
- the PDF bytes directly to the configured `DocumentStore`.
139
- 7. Form and process state receive only the stored PDF's `{ fileId, filename }`
140
- reference. Process models parse this artifact where an attachment or other
141
- consumer needs it.
142
- 8. `parseGoogleDriveGeneratedPdf` validates generated-PDF references, while
143
- `parseGoogleDriveValue` validates and parses metadata-only values using
144
- Effect Schema in downstream process steps.
145
-
146
- ## Credentials
147
-
148
- OAuth bearer tokens are kept only in browser module memory for the active page.
149
- An expiry-aware cache lets remounted picker fields reuse a token until one
150
- minute before expiry, and plugin cleanup clears all cached tokens. Tokens must
151
- not be written to browser storage, form values, process state, GraphQL
152
- variables, queues, logs, or database rows. Google export URLs and browser blob
153
- URLs must not be persisted either. Persist only the document-store `fileId` and
154
- safe display metadata such as `filename`.
155
-
156
- ## Supported PDF sources
157
-
158
- PDF generation accepts Google Docs, Sheets, Slides, Drawings, and existing PDF
159
- files. The picker filters out other MIME types. If another Google Drive type is
160
- needed, first confirm that Drive can export it as `application/pdf`; do not add
161
- a server-side token transfer as a workaround.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { GoogleDrive } from "./lib/google-drive.js";
2
+ export { GoogleDriveConfiguration, makeGoogleDriveConfiguration, readGoogleDrivePickerConfiguration, } from "./lib/google-drive-configuration.js";
2
3
  export type { DrivePickerFile, GoogleDriveFieldOptions, GoogleDriveGeneratedPdf, } from "./lib/google-drive-field.js";
3
4
  export { DrivePickerFileSchema, FormGoogleDriveGeneratePdf, FormGoogleDriveInput, GoogleDriveField, GoogleDriveGeneratedPdfSchema, isGoogleDriveGeneratedPdf, parseGoogleDriveGeneratedPdf, parseGoogleDriveValue, } from "./lib/google-drive-field.js";
package/dist/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ import { registerGoogleDriveWalkerPlugin } from "./lib/register-walker.js";
2
+ registerGoogleDriveWalkerPlugin();
1
3
  export { GoogleDrive } from "./lib/google-drive.js";
4
+ export { GoogleDriveConfiguration, makeGoogleDriveConfiguration, readGoogleDrivePickerConfiguration, } from "./lib/google-drive-configuration.js";
2
5
  export { DrivePickerFileSchema, FormGoogleDriveGeneratePdf, FormGoogleDriveInput, GoogleDriveField, GoogleDriveGeneratedPdfSchema, isGoogleDriveGeneratedPdf, parseGoogleDriveGeneratedPdf, parseGoogleDriveValue, } from "./lib/google-drive-field.js";
3
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAMhD,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,oBAAoB,EACpB,gBAAgB,EAChB,6BAA6B,EAC7B,yBAAyB,EACzB,4BAA4B,EAC5B,qBAAqB,GACtB,MAAM,0BAA0B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAA;AAEvE,+BAA+B,EAAE,CAAA;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,kCAAkC,GACnC,MAAM,kCAAkC,CAAA;AAMzC,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,oBAAoB,EACpB,gBAAgB,EAChB,6BAA6B,EAC7B,yBAAyB,EACzB,4BAA4B,EAC5B,qBAAqB,GACtB,MAAM,0BAA0B,CAAA"}
@@ -0,0 +1,35 @@
1
+ import type { GoogleDrivePickerConfiguration } from "./google-drive-picker-config.js";
2
+ export declare const makeGoogleDriveConfiguration: (bindings?: {
3
+ readonly clientId?: string;
4
+ readonly appId?: string;
5
+ readonly developerKey?: string;
6
+ }) => {
7
+ owner: string;
8
+ target: string;
9
+ fields: {
10
+ clientId: import("@processfocus/runtime").ConfigurationField<string>;
11
+ appId: import("@processfocus/runtime").ConfigurationField<string>;
12
+ developerKey: import("@processfocus/runtime").ConfigurationField<string>;
13
+ };
14
+ rules: never[];
15
+ };
16
+ export declare const GoogleDriveConfiguration: {
17
+ owner: string;
18
+ target: string;
19
+ fields: {
20
+ clientId: import("@processfocus/runtime").ConfigurationField<string>;
21
+ appId: import("@processfocus/runtime").ConfigurationField<string>;
22
+ developerKey: import("@processfocus/runtime").ConfigurationField<string>;
23
+ };
24
+ rules: never[];
25
+ };
26
+ export declare const readGoogleDrivePickerConfiguration: (configuration?: {
27
+ owner: string;
28
+ target: string;
29
+ fields: {
30
+ clientId: import("@processfocus/runtime").ConfigurationField<string>;
31
+ appId: import("@processfocus/runtime").ConfigurationField<string>;
32
+ developerKey: import("@processfocus/runtime").ConfigurationField<string>;
33
+ };
34
+ rules: never[];
35
+ }) => GoogleDrivePickerConfiguration;
@@ -0,0 +1,23 @@
1
+ import { configurationField, configurationString, readConfiguration, } from "@processfocus/runtime";
2
+ import { Config, ConfigProvider, Effect } from "effect";
3
+ export const makeGoogleDriveConfiguration = (bindings = {}) => {
4
+ const clientId = bindings.clientId ?? "GOOGLE_DRIVE_PICKER_CLIENT_ID";
5
+ const appId = bindings.appId ?? "GOOGLE_DRIVE_PICKER_APP_ID";
6
+ const developerKey = bindings.developerKey ?? "GOOGLE_DRIVE_PICKER_DEVELOPER_KEY";
7
+ // Absent values leave the picker unconfigured instead of blocking
8
+ // deployment; supplied values must still be nonblank.
9
+ const optionalPickerValue = (key) => configurationString(key).pipe(Config.withDefault(""));
10
+ return {
11
+ owner: "form.google-drive",
12
+ target: "form-projection",
13
+ fields: {
14
+ clientId: configurationField(clientId, optionalPickerValue(clientId)),
15
+ appId: configurationField(appId, optionalPickerValue(appId)),
16
+ developerKey: configurationField(developerKey, optionalPickerValue(developerKey)),
17
+ },
18
+ rules: [],
19
+ };
20
+ };
21
+ export const GoogleDriveConfiguration = makeGoogleDriveConfiguration();
22
+ export const readGoogleDrivePickerConfiguration = (configuration = GoogleDriveConfiguration) => Effect.runSync(readConfiguration(configuration).pipe(Effect.provideService(ConfigProvider.ConfigProvider, ConfigProvider.fromEnv())));
23
+ //# sourceMappingURL=google-drive-configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-drive-configuration.js","sourceRoot":"","sources":["../../src/lib/google-drive-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAGvD,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,QAAQ,GAIJ,EAAE,EACN,EAAE;IACF,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,IAAI,+BAA+B,CAAA;IACrE,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,IAAI,4BAA4B,CAAA;IAC5D,MAAM,YAAY,GAChB,QAAQ,CAAC,YAAY,IAAI,mCAAmC,CAAA;IAC9D,kEAAkE;IAClE,sDAAsD;IACtD,MAAM,mBAAmB,GAAG,CAAC,GAAW,EAAE,EAAE,CAC1C,mBAAmB,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAA;IACvD,OAAO;QACL,KAAK,EAAE,mBAAmB;QAC1B,MAAM,EAAE,iBAAiB;QACzB,MAAM,EAAE;YACN,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;YACrE,KAAK,EAAE,kBAAkB,CAAC,KAAK,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC;YAC5D,YAAY,EAAE,kBAAkB,CAC9B,YAAY,EACZ,mBAAmB,CAAC,YAAY,CAAC,CAClC;SACF;QACD,KAAK,EAAE,EAAE;KACmB,CAAA;AAChC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG,4BAA4B,EAAE,CAAA;AAEtE,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAChD,aAAa,GAAG,wBAAwB,EACR,EAAE,CAClC,MAAM,CAAC,OAAO,CACZ,iBAAiB,CAAC,aAAa,CAAC,CAAC,IAAI,CACnC,MAAM,CAAC,cAAc,CACnB,cAAc,CAAC,cAAc,EAC7B,cAAc,CAAC,OAAO,EAAE,CACzB,CACF,CACF,CAAA"}
@@ -23,8 +23,8 @@ export interface GoogleDriveFieldOptions extends FieldOptions<string> {
23
23
  }
24
24
  /** Stored document reference produced by the browser PDF upload flow. */
25
25
  export declare const GoogleDriveGeneratedPdfSchema: Schema.Struct<{
26
- fileId: typeof Schema.NonEmptyString;
27
- filename: typeof Schema.NonEmptyString;
26
+ readonly fileId: Schema.NonEmptyString;
27
+ readonly filename: Schema.NonEmptyString;
28
28
  }>;
29
29
  export type GoogleDriveGeneratedPdf = typeof GoogleDriveGeneratedPdfSchema.Type;
30
30
  /** Parse a generated-PDF form value into its stored document reference. */
@@ -46,16 +46,16 @@ export declare const isGoogleDriveGeneratedPdf: (value: string) => boolean;
46
46
  * })
47
47
  * ```
48
48
  */
49
- export declare const GoogleDriveField: (options?: GoogleDriveFieldOptions) => Schema.Schema<string, string, never>;
49
+ export declare const GoogleDriveField: (options?: GoogleDriveFieldOptions) => Schema.Codec<string, string, never, never>;
50
50
  /**
51
51
  * Schema for validated Google Drive file metadata.
52
52
  * Public process-state values never include bearer tokens.
53
53
  */
54
54
  export declare const DrivePickerFileSchema: Schema.Struct<{
55
- id: typeof Schema.String;
56
- name: typeof Schema.String;
57
- mimeType: typeof Schema.String;
58
- url: typeof Schema.String;
55
+ readonly id: Schema.String;
56
+ readonly name: Schema.String;
57
+ readonly mimeType: Schema.String;
58
+ readonly url: Schema.String;
59
59
  }>;
60
60
  export type DrivePickerFile = typeof DrivePickerFileSchema.Type;
61
61
  /**
@@ -1,19 +1,14 @@
1
1
  import { Option, Schema } from "effect";
2
- import { FormComponentPluginType, FormFileInput, applyFieldAnnotations, } from "processfocus/forms";
2
+ import { FormComponentPluginType, FormFileInput, FormPluginData, applyFieldAnnotations, } from "processfocus/forms";
3
3
  import { FormGoogleDriveGeneratePdf, FormGoogleDriveInput, } from "./google-drive-annotations.js";
4
4
  import { GOOGLE_DRIVE_CLIENT_MODULE, GOOGLE_DRIVE_PLUGIN_TYPE, } from "./plugin-identity.js";
5
- import { registerGoogleDriveWalkerPlugin } from "./register-walker.js";
6
5
  export { FormGoogleDriveGeneratePdf, FormGoogleDriveInput };
7
- // Organisation bundles contain their own runtime plugin registry. Registering
8
- // while the field module loads keeps the walker and its registry in that same
9
- // JavaScript realm, even when the host runtime has a separate registry copy.
10
- registerGoogleDriveWalkerPlugin();
11
6
  /** Stored document reference produced by the browser PDF upload flow. */
12
7
  export const GoogleDriveGeneratedPdfSchema = Schema.Struct({
13
8
  fileId: Schema.NonEmptyString,
14
9
  filename: Schema.NonEmptyString,
15
10
  });
16
- const GoogleDriveGeneratedPdfJsonSchema = Schema.parseJson(GoogleDriveGeneratedPdfSchema);
11
+ const GoogleDriveGeneratedPdfJsonSchema = Schema.fromJsonString(GoogleDriveGeneratedPdfSchema);
17
12
  /** Parse a generated-PDF form value into its stored document reference. */
18
13
  export const parseGoogleDriveGeneratedPdf = (value) => Schema.decodeUnknownSync(GoogleDriveGeneratedPdfJsonSchema, {
19
14
  onExcessProperty: "error",
@@ -46,16 +41,19 @@ export const GoogleDriveField = (options) => {
46
41
  : `/${documentStore}`;
47
42
  const valueSchema = normalizedDocumentStore === undefined
48
43
  ? Schema.String
49
- : Schema.String.pipe(Schema.filter(isGoogleDriveGeneratedPdf, {
50
- message: () => "Select a Google Drive file and wait for its PDF upload to finish",
51
- }));
52
- return applyFieldAnnotations(valueSchema.annotations({
44
+ : Schema.String.pipe(Schema.check(Schema.makeFilter(isGoogleDriveGeneratedPdf, {
45
+ message: "Select a Google Drive file and wait for its PDF upload to finish",
46
+ })));
47
+ return applyFieldAnnotations(valueSchema.annotate({
53
48
  [FormComponentPluginType]: {
54
49
  module: GOOGLE_DRIVE_CLIENT_MODULE,
55
50
  type: GOOGLE_DRIVE_PLUGIN_TYPE,
56
51
  },
57
52
  [FormGoogleDriveInput]: true,
58
53
  ...(normalizedDocumentStore !== undefined && {
54
+ [FormPluginData]: {
55
+ generatePdf: { documentStore: normalizedDocumentStore },
56
+ },
59
57
  [FormGoogleDriveGeneratePdf]: {
60
58
  documentStore: normalizedDocumentStore,
61
59
  },
@@ -83,7 +81,7 @@ export const DrivePickerFileSchema = Schema.Struct({
83
81
  * console.log(file.name, file.url)
84
82
  * ```
85
83
  */
86
- export const parseGoogleDriveValue = (value) => Schema.decodeUnknownSync(Schema.parseJson(DrivePickerFileSchema), {
84
+ export const parseGoogleDriveValue = (value) => Schema.decodeUnknownSync(Schema.fromJsonString(DrivePickerFileSchema), {
87
85
  onExcessProperty: "error",
88
86
  })(value);
89
87
  //# sourceMappingURL=google-drive-field.js.map
@@ -1 +1 @@
1
- {"version":3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CAAC,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,QAAQ,EAAE,MAAM,CAAC,MAAM;IACvB,GAAG,EAAE,MAAM,CAAC,MAAM;CACnB,CAAC,CAAA;AAIF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAa,EAAmB,EAAE,CACtE,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,cAAc,CAAC,qBAAqB,CAAC,EAAE;IACrE,gBAAgB,EAAE,OAAO;CAC1B,CAAC,CAAC,KAAK,CAAC,CAAA"}
@@ -1,10 +1,6 @@
1
1
  import type { GoogleDrivePluginData } from "./plugin-data.js";
2
2
  export declare const GOOGLE_DRIVE_NOT_CONFIGURED_USER_MESSAGE = "Google Drive is not configured. Contact your administrator.";
3
3
  export type GoogleDrivePickerConfiguration = Pick<GoogleDrivePluginData, "clientId" | "appId" | "developerKey">;
4
- /**
5
- * Read public Google Picker configuration from the server runtime.
6
- */
7
- export declare const readGoogleDrivePickerConfiguration: () => GoogleDrivePickerConfiguration;
8
4
  export declare const googleDrivePickerConfigurationDiagnostics: (input: {
9
5
  readonly clientId: string;
10
6
  readonly appId: string;
@@ -1,17 +1,4 @@
1
1
  export const GOOGLE_DRIVE_NOT_CONFIGURED_USER_MESSAGE = "Google Drive is not configured. Contact your administrator.";
2
- /**
3
- * Read public Google Picker configuration from the server runtime.
4
- */
5
- export const readGoogleDrivePickerConfiguration = () => {
6
- const clientId = process.env["GOOGLE_DRIVE_PICKER_CLIENT_ID"];
7
- const appId = process.env["GOOGLE_DRIVE_PICKER_APP_ID"];
8
- const developerKey = process.env["GOOGLE_DRIVE_PICKER_DEVELOPER_KEY"];
9
- return {
10
- ...(clientId !== undefined && { clientId }),
11
- ...(appId !== undefined && { appId }),
12
- ...(developerKey !== undefined && { developerKey }),
13
- };
14
- };
15
2
  export const googleDrivePickerConfigurationDiagnostics = (input) => {
16
3
  const diagnostics = [];
17
4
  if (!input.clientId) {
@@ -1 +1 @@
1
- {"version":3,"file":"google-drive-picker-config.js","sourceRoot":"","sources":["../../src/lib/google-drive-picker-config.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,wCAAwC,GACnD,6DAA6D,CAAA;AAO/D;;GAEG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAC7C,GAAmC,EAAE;IACnC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAA;IAC7D,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;IACvD,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAA;IACrE,OAAO;QACL,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC3C,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,CAAC;QACrC,GAAG,CAAC,YAAY,KAAK,SAAS,IAAI,EAAE,YAAY,EAAE,CAAC;KACpD,CAAA;AACH,CAAC,CAAA;AAEH,MAAM,CAAC,MAAM,yCAAyC,GAAG,CAAC,KAIzD,EAAqB,EAAE;IACtB,MAAM,WAAW,GAAa,EAAE,CAAA;IAChC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACpB,WAAW,CAAC,IAAI,CACd,iFAAiF,CAClF,CAAA;IACH,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACjB,WAAW,CAAC,IAAI,CACd,8EAA8E,CAC/E,CAAA;IACH,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;QACxB,WAAW,CAAC,IAAI,CACd,qFAAqF,CACtF,CAAA;IACH,CAAC;IACD,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA"}
1
+ {"version":3,"file":"google-drive-picker-config.js","sourceRoot":"","sources":["../../src/lib/google-drive-picker-config.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,wCAAwC,GACnD,6DAA6D,CAAA;AAO/D,MAAM,CAAC,MAAM,yCAAyC,GAAG,CAAC,KAIzD,EAAqB,EAAE;IACtB,MAAM,WAAW,GAAa,EAAE,CAAA;IAChC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACpB,WAAW,CAAC,IAAI,CACd,iFAAiF,CAClF,CAAA;IACH,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACjB,WAAW,CAAC,IAAI,CACd,8EAA8E,CAC/E,CAAA;IACH,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;QACxB,WAAW,CAAC,IAAI,CACd,qFAAqF,CACtF,CAAA;IACH,CAAC;IACD,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA"}
@@ -3,7 +3,7 @@ import type { OrganisationBrowserPluginArtifactProvider, OrganisationBrowserPlug
3
3
  /**
4
4
  * Declares Google Drive as organisation-owned browser and server behavior.
5
5
  *
6
- * Importing the plugin's field API registers its walker in the organisation
6
+ * Importing the plugin's server entrypoint registers its walker in the organisation
7
7
  * bundle realm. This construct makes the matching browser renderer and its
8
8
  * build-time stylesheet part of the same organisation artifact.
9
9
  */
@@ -4,7 +4,7 @@ import { GOOGLE_DRIVE_CLIENT_MODULE, GOOGLE_DRIVE_PLUGIN_TYPE, } from "./plugin-
4
4
  /**
5
5
  * Declares Google Drive as organisation-owned browser and server behavior.
6
6
  *
7
- * Importing the plugin's field API registers its walker in the organisation
7
+ * Importing the plugin's server entrypoint registers its walker in the organisation
8
8
  * bundle realm. This construct makes the matching browser renderer and its
9
9
  * build-time stylesheet part of the same organisation artifact.
10
10
  */
@@ -49,11 +49,22 @@ export const organisationFrontendPlugin = {
49
49
  activate: (host) => {
50
50
  host.formRenderers.register({
51
51
  type: GOOGLE_DRIVE_PLUGIN_TYPE,
52
+ scripts: [
53
+ { src: "https://accounts.google.com/gsi/client", async: true },
54
+ { src: "https://apis.google.com/js/api.js", async: true },
55
+ ],
52
56
  renderer: (form, component, shouldAutoFocus, options) => {
53
57
  const AppField = form.AppField;
54
58
  const pluginData = component.pluginData;
55
59
  return (_jsx(AppField, { name: component.field, children: (field) => (_jsx(Suspense, { fallback: _jsxs("div", { className: "animate-pulse space-y-2", children: [_jsx("div", { className: "bg-muted h-4 w-1/3 rounded" }), _jsx("div", { className: "bg-muted h-10 w-32 rounded" })] }), children: _jsx(host.graphql.ClientConsumer, { children: (graphqlClient) => {
56
- const picker = (hint) => (_jsx(LazyGoogleDrivePicker, { field: field, label: component.label, autoFocus: shouldAutoFocus, requestUploadUrl: (input) => requestUploadUrl(graphqlClient, input), requestDownloadUrl: (input) => requestDownloadUrl(graphqlClient, input), deleteFile: (fileId) => deleteFile(graphqlClient, fileId), ...(pluginData?.clientId !== undefined && {
60
+ const picker = (hint) => (_jsx(LazyGoogleDrivePicker, { field: {
61
+ state: {
62
+ value: typeof field.state.value === "string"
63
+ ? field.state.value
64
+ : "",
65
+ },
66
+ handleChange: field.handleChange,
67
+ }, label: component.label, autoFocus: shouldAutoFocus, requestUploadUrl: (input) => requestUploadUrl(graphqlClient, input), requestDownloadUrl: (input) => requestDownloadUrl(graphqlClient, input), deleteFile: (fileId) => deleteFile(graphqlClient, fileId), ...(pluginData?.clientId !== undefined && {
57
68
  clientId: pluginData.clientId,
58
69
  }), ...(pluginData?.appId !== undefined && {
59
70
  appId: pluginData.appId,
@@ -1 +1 @@
1
- {"version":3,"file":"register-client.js","sourceRoot":"","sources":["../../src/lib/register-client.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAOtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAE5D,qFAAqF;AACrF,MAAM,qBAAqB,GAAG,IAAI,CAAC,GAAG,EAAE,CACtC,MAAM,CAAC,uBAAuB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,C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ACrB,IAAI,KAAK,EAAE,IAAI;wCACb,IAAI;qCACL,CAAC,KACA,CAAC,OAAO,EAAE,QAAQ,KAAK,SAAS,IAAI;wCACtC,QAAQ,EAAE,OAAO,CAAC,QAAQ;qCAC3B,CAAC,KACE,CAAC,SAAS,CAAC,WAAW,KAAK,SAAS,IAAI;wCAC1C,WAAW,EAAE,SAAS,CAAC,WAAW;qCACnC,CAAC,KACE,CAAC,SAAS,CAAC,QAAQ,KAAK,SAAS,IAAI;wCACvC,QAAQ,EAAE,SAAS,CAAC,QAAQ;qCAC7B,CAAC,GACF,CACH,CAAA;gCACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;oCAClB,OAAO,MAAM,EAAE,CAAA;gCACjB,CAAC;gCACD,OAAO,CACL,KAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,cACnB,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GACb,CACzB,CAAA;4BACH,CAAC,GAC2B,GACrB,CACZ,IAxEY,SAAS,CAAC,KAAK,CAyEnB,CACZ,CAAA;YACH,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;CACmC,CAAA"}
@@ -13,4 +13,13 @@
13
13
  * SRI hashes are not applied because both endpoints serve version-less
14
14
  * bundles whose content changes without notice.
15
15
  */
16
- export declare const registerGoogleDriveWalkerPlugin: () => void;
16
+ export declare const registerGoogleDriveWalkerPlugin: (configuration?: {
17
+ owner: string;
18
+ target: string;
19
+ fields: {
20
+ clientId: import("@processfocus/runtime").ConfigurationField<string>;
21
+ appId: import("@processfocus/runtime").ConfigurationField<string>;
22
+ developerKey: import("@processfocus/runtime").ConfigurationField<string>;
23
+ };
24
+ rules: never[];
25
+ }) => void;
@@ -1,6 +1,6 @@
1
1
  import { registerWalkerPlugin } from "@processfocus/runtime";
2
2
  import { FormGoogleDriveGeneratePdf, FormGoogleDriveInput, } from "./google-drive-annotations.js";
3
- import { readGoogleDrivePickerConfiguration } from "./google-drive-picker-config.js";
3
+ import { GoogleDriveConfiguration, readGoogleDrivePickerConfiguration, } from "./google-drive-configuration.js";
4
4
  import { clearPickerTokenCache } from "./picker-token-cache.js";
5
5
  import { GOOGLE_DRIVE_PLUGIN_TYPE } from "./plugin-identity.js";
6
6
  /**
@@ -18,7 +18,7 @@ import { GOOGLE_DRIVE_PLUGIN_TYPE } from "./plugin-identity.js";
18
18
  * SRI hashes are not applied because both endpoints serve version-less
19
19
  * bundles whose content changes without notice.
20
20
  */
21
- export const registerGoogleDriveWalkerPlugin = () => {
21
+ export const registerGoogleDriveWalkerPlugin = (configuration = GoogleDriveConfiguration) => {
22
22
  registerWalkerPlugin({
23
23
  type: GOOGLE_DRIVE_PLUGIN_TYPE,
24
24
  matchAnnotation(annotations) {
@@ -27,12 +27,14 @@ export const registerGoogleDriveWalkerPlugin = () => {
27
27
  extractData(annotations) {
28
28
  // Public Picker configuration is read here on the server and sent to the
29
29
  // renderer through field pluginData. These values are not secrets.
30
- const { clientId, appId, developerKey } = readGoogleDrivePickerConfiguration();
30
+ // Unconfigured environments omit the values so forms degrade to the
31
+ // "Google Drive is not configured" renderer state.
32
+ const { clientId, appId, developerKey } = readGoogleDrivePickerConfiguration(configuration);
31
33
  const generatePdf = annotations[FormGoogleDriveGeneratePdf];
32
34
  return {
33
- ...(clientId !== undefined && { clientId }),
34
- ...(appId !== undefined && { appId }),
35
- ...(developerKey !== undefined && { developerKey }),
35
+ ...(clientId !== "" && { clientId }),
36
+ ...(appId !== "" && { appId }),
37
+ ...(developerKey !== "" && { developerKey }),
36
38
  ...(typeof generatePdf === "object" &&
37
39
  generatePdf !== null &&
38
40
  "documentStore" in generatePdf &&
@@ -1 +1 @@
1
- {"version":3,"file":"register-walker.js","sourceRoot":"","sources":["../../src/lib/register-walker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM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,eAAe,IAAI,WAAW;oBAC9B,OAAO,WAAW,CAAC,aAAa,KAAK,QAAQ,IAAI;oBAC/C,WAAW,EAAE,EAAE,aAAa,EAAE,WAAW,CAAC,aAAa,EAAE;iBAC1D,CAAC;aACL,CAAA;QACH,CAAC;QACD,OAAO,EAAE;YACP;gBACE,EAAE,EAAE,0BAA0B;gBAC9B,GAAG,EAAE,wCAAwC;gBAC7C,KAAK,EAAE,IAAI;aACZ;YACD;gBACE,EAAE,EAAE,mBAAmB;gBACvB,GAAG,EAAE,mCAAmC;gBACxC,KAAK,EAAE,IAAI;aACZ;SACF;QACD,OAAO,EAAE,qBAAqB;KAC/B,CAAC,CAAA;AACJ,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@processfocus/plugin-google-drive",
3
- "version": "0.1.0-next.2",
3
+ "version": "0.1.0-next.4",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "repository": {
@@ -43,7 +43,12 @@
43
43
  "import": "./dist/lib/prepare-client.js",
44
44
  "default": "./dist/lib/prepare-client.js"
45
45
  },
46
- "./styles.css": "./styles.css"
46
+ "./styles.css": "./styles.css",
47
+ "./field": {
48
+ "types": "./dist/lib/google-drive-field.d.ts",
49
+ "import": "./dist/lib/google-drive-field.js",
50
+ "default": "./dist/lib/google-drive-field.js"
51
+ }
47
52
  },
48
53
  "files": [
49
54
  "dist",
@@ -55,13 +60,13 @@
55
60
  "dependencies": {
56
61
  "@googleworkspace/drive-picker-element": "^0.7.3",
57
62
  "constructs": "^10.8.1",
58
- "effect": "^3.22.2",
59
- "tailwindcss": "4.3.3"
63
+ "effect": "4.1.4",
64
+ "tailwindcss": "4.3.5"
60
65
  },
61
66
  "peerDependencies": {
62
67
  "react": "^19.2.8",
63
- "processfocus": "0.1.0-next.2",
64
- "@processfocus/runtime": "0.1.0-next.2"
68
+ "processfocus": "0.1.0-next.4",
69
+ "@processfocus/runtime": "0.1.0-next.4"
65
70
  },
66
71
  "publishConfig": {
67
72
  "access": "public",