plenna_utilities 1.4.0 → 1.5.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.
@@ -16,6 +16,10 @@ interface deleteDocumentResponse {
16
16
  }
17
17
  export interface ISchemaRequest extends docs_v1.Schema$Request {
18
18
  }
19
+ export interface IInsertText extends docs_v1.Schema$InsertTextRequest {
20
+ }
21
+ export interface ITextStyles extends docs_v1.Schema$UpdateTextStyleRequest {
22
+ }
19
23
  export interface ICredentials extends JWTInput {
20
24
  }
21
25
  export declare class PlennaGoogleService {
@@ -24,7 +28,8 @@ export declare class PlennaGoogleService {
24
28
  authorization(): GoogleAuth<JSONClient>;
25
29
  getDocument(documentId: string): Promise<docs_v1.Schema$Document | undefined>;
26
30
  cloneDocument(documentId: string, folderId: string): Promise<cloneDocumentResponse>;
27
- buildPayload(template?: IPlennaGoogleBase[]): ISchemaRequest[];
31
+ buildPayload(template?: Array<Partial<IPlennaGoogleBase>>): ISchemaRequest[];
32
+ addTextToRequest(text: IInsertText, style: ITextStyles): ISchemaRequest[];
28
33
  updateDocument(id: string, requests?: ISchemaRequest[]): Promise<updateDocumentResponse>;
29
34
  exportDocumentAsUrl(fileId: string): Promise<string | undefined>;
30
35
  exportDocumentAsFile(fileId: string): Promise<ArrayBuffer | undefined>;
@@ -51,6 +51,16 @@ class PlennaGoogleService {
51
51
  buildPayload(template = []) {
52
52
  return (0, requestBuilder_1.payloadBuilder)(template);
53
53
  }
54
+ addTextToRequest(text, style) {
55
+ return [
56
+ {
57
+ insertText: text
58
+ },
59
+ {
60
+ updateTextStyle: style
61
+ }
62
+ ];
63
+ }
54
64
  async updateDocument(id, requests = []) {
55
65
  const authClient = this.authorization();
56
66
  const client = new docs_1.docs_v1.Docs({ auth: authClient });
@@ -11,4 +11,4 @@ export interface IPlennaGoogleBase {
11
11
  rowIndex?: number;
12
12
  };
13
13
  }
14
- export declare const payloadBuilder: (template: IPlennaGoogleBase[]) => docs_v1.Schema$Request[];
14
+ export declare const payloadBuilder: (template: Array<Partial<IPlennaGoogleBase>>) => docs_v1.Schema$Request[];
@@ -47,9 +47,11 @@ const getPayload = (type, variable, value, rowToDelete) => {
47
47
  const payloadBuilder = (template) => {
48
48
  const payload = [];
49
49
  template.forEach(field => {
50
- const val = getPayload(field.doc_type, field.identifier, field.value, field.rowToDelete);
51
- if (val !== undefined) {
52
- payload.push(val);
50
+ if (field.doc_type !== undefined) {
51
+ const val = getPayload(field.doc_type, field.identifier, field.value, field.rowToDelete);
52
+ if (val !== undefined) {
53
+ payload.push(val);
54
+ }
53
55
  }
54
56
  });
55
57
  console.log(payload);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plenna_utilities",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "plenna's utils for backend projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",