brother-smooth-print-uri 1.0.0 → 1.2.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.
package/README.md CHANGED
@@ -9,12 +9,21 @@ Learn more about Brother Smooth Print [here](https://support.brother.com/g/s/es/
9
9
  ```typescript
10
10
  import { generatePrintUri } from "brother-smooth-print-uri";
11
11
 
12
+ // Using filename and size URLs
12
13
  const uri = generatePrintUri({
13
14
  filename: "https://example.com/Simple.lbx",
14
15
  size: "https://example.com/26x76.bin",
15
16
  });
17
+
18
+ // Or using base64-encoded file attachments
19
+ const uriWithAttachments = generatePrintUri({
20
+ fileattach: "base64EncodedLbxData",
21
+ sizeattach: "base64EncodedBinData",
22
+ });
16
23
  ```
17
24
 
25
+ **Note:** You must provide exactly one of `filename` or `fileattach`, and exactly one of `size` or `sizeattach`. Providing both or neither will throw an error.
26
+
18
27
  See more examples in the tests: [src/uri-generator.test.ts](src/uri-generator.test.ts).
19
28
 
20
29
  This package only creates the URI, it does not initiate the actual print job.
package/dist/index.d.mts CHANGED
@@ -1,17 +1,19 @@
1
1
  /**
2
- * Brother Smooth Print arguments as defined here: https://support.brother.com/g/s/es/dev/en/specific/smooth_print/index.html?c=eu_ot&lang=en&comple=on&redirect=on
2
+ * Base interface for Brother Smooth Print arguments as defined here: https://support.brother.com/g/s/es/dev/en/specific/smooth_print/index.html?c=eu_ot&lang=en&comple=on&redirect=on
3
3
  */
4
- interface BrotherArgs {
4
+ interface BrotherArgsBase {
5
5
  /**
6
6
  * Single layout template file (.lbx)
7
+ * Required unless fileattach is provided. Exactly one of filename or fileattach must be provided.
7
8
  * @example https://example.com/Simple.lbx
8
9
  */
9
- filename: string;
10
+ filename?: string;
10
11
  /**
11
12
  * Media settings file (bin)
13
+ * Required unless sizeattach is provided. Exactly one of size or sizeattach must be provided.
12
14
  * @example https://example.com/26x76.bin
13
15
  */
14
- size: string;
16
+ size?: string;
15
17
  /**
16
18
  * Number of copies to print
17
19
  * @example 1
@@ -99,10 +101,12 @@ interface BrotherArgs {
99
101
  /**
100
102
  * Set the base64 data as a print file to attach to a URL scheme.
101
103
  * (single layout)
104
+ * Required unless filename is provided. Exactly one of filename or fileattach must be provided.
102
105
  */
103
106
  fileattach?: string;
104
107
  /**
105
108
  * Set the base64 data as a media information file to attach to a URL scheme.
109
+ * Required unless size is provided. Exactly one of size or sizeattach must be provided.
106
110
  */
107
111
  sizeattach?: string;
108
112
  /**
@@ -117,7 +121,32 @@ interface BrotherArgs {
117
121
  */
118
122
  forceStretchPrintableArea?: boolean;
119
123
  }
124
+ /**
125
+ * Helper type for file source - exactly one of filename or fileattach
126
+ */
127
+ type FileSource = (Required<Pick<BrotherArgsBase, 'filename'>> & {
128
+ fileattach?: never;
129
+ }) | (Required<Pick<BrotherArgsBase, 'fileattach'>> & {
130
+ filename?: never;
131
+ });
132
+ /**
133
+ * Helper type for size source - exactly one of size or sizeattach
134
+ */
135
+ type SizeSource = (Required<Pick<BrotherArgsBase, 'size'>> & {
136
+ sizeattach?: never;
137
+ }) | (Required<Pick<BrotherArgsBase, 'sizeattach'>> & {
138
+ size?: never;
139
+ });
140
+ /**
141
+ * Brother Smooth Print arguments with exactly one of filename or fileattach,
142
+ * and exactly one of size or sizeattach.
143
+ *
144
+ * This type enforces at compile-time that you must provide:
145
+ * - Exactly one file source (filename OR fileattach)
146
+ * - Exactly one size source (size OR sizeattach)
147
+ */
148
+ type BrotherArgs = Omit<BrotherArgsBase, 'filename' | 'fileattach' | 'size' | 'sizeattach'> & FileSource & SizeSource;
120
149
 
121
150
  declare const generatePrintUri: (args: BrotherArgs) => URL;
122
151
 
123
- export { type BrotherArgs, generatePrintUri };
152
+ export { type BrotherArgs, type BrotherArgsBase, generatePrintUri };
package/dist/index.d.ts CHANGED
@@ -1,17 +1,19 @@
1
1
  /**
2
- * Brother Smooth Print arguments as defined here: https://support.brother.com/g/s/es/dev/en/specific/smooth_print/index.html?c=eu_ot&lang=en&comple=on&redirect=on
2
+ * Base interface for Brother Smooth Print arguments as defined here: https://support.brother.com/g/s/es/dev/en/specific/smooth_print/index.html?c=eu_ot&lang=en&comple=on&redirect=on
3
3
  */
4
- interface BrotherArgs {
4
+ interface BrotherArgsBase {
5
5
  /**
6
6
  * Single layout template file (.lbx)
7
+ * Required unless fileattach is provided. Exactly one of filename or fileattach must be provided.
7
8
  * @example https://example.com/Simple.lbx
8
9
  */
9
- filename: string;
10
+ filename?: string;
10
11
  /**
11
12
  * Media settings file (bin)
13
+ * Required unless sizeattach is provided. Exactly one of size or sizeattach must be provided.
12
14
  * @example https://example.com/26x76.bin
13
15
  */
14
- size: string;
16
+ size?: string;
15
17
  /**
16
18
  * Number of copies to print
17
19
  * @example 1
@@ -99,10 +101,12 @@ interface BrotherArgs {
99
101
  /**
100
102
  * Set the base64 data as a print file to attach to a URL scheme.
101
103
  * (single layout)
104
+ * Required unless filename is provided. Exactly one of filename or fileattach must be provided.
102
105
  */
103
106
  fileattach?: string;
104
107
  /**
105
108
  * Set the base64 data as a media information file to attach to a URL scheme.
109
+ * Required unless size is provided. Exactly one of size or sizeattach must be provided.
106
110
  */
107
111
  sizeattach?: string;
108
112
  /**
@@ -117,7 +121,32 @@ interface BrotherArgs {
117
121
  */
118
122
  forceStretchPrintableArea?: boolean;
119
123
  }
124
+ /**
125
+ * Helper type for file source - exactly one of filename or fileattach
126
+ */
127
+ type FileSource = (Required<Pick<BrotherArgsBase, 'filename'>> & {
128
+ fileattach?: never;
129
+ }) | (Required<Pick<BrotherArgsBase, 'fileattach'>> & {
130
+ filename?: never;
131
+ });
132
+ /**
133
+ * Helper type for size source - exactly one of size or sizeattach
134
+ */
135
+ type SizeSource = (Required<Pick<BrotherArgsBase, 'size'>> & {
136
+ sizeattach?: never;
137
+ }) | (Required<Pick<BrotherArgsBase, 'sizeattach'>> & {
138
+ size?: never;
139
+ });
140
+ /**
141
+ * Brother Smooth Print arguments with exactly one of filename or fileattach,
142
+ * and exactly one of size or sizeattach.
143
+ *
144
+ * This type enforces at compile-time that you must provide:
145
+ * - Exactly one file source (filename OR fileattach)
146
+ * - Exactly one size source (size OR sizeattach)
147
+ */
148
+ type BrotherArgs = Omit<BrotherArgsBase, 'filename' | 'fileattach' | 'size' | 'sizeattach'> & FileSource & SizeSource;
120
149
 
121
150
  declare const generatePrintUri: (args: BrotherArgs) => URL;
122
151
 
123
- export { type BrotherArgs, generatePrintUri };
152
+ export { type BrotherArgs, type BrotherArgsBase, generatePrintUri };
package/dist/index.js CHANGED
@@ -25,10 +25,41 @@ __export(src_exports, {
25
25
  module.exports = __toCommonJS(src_exports);
26
26
 
27
27
  // src/uri-generator.ts
28
+ var hasFilename = (args) => {
29
+ return "filename" in args && typeof args.filename === "string";
30
+ };
31
+ var hasFileattach = (args) => {
32
+ return "fileattach" in args && typeof args.fileattach === "string";
33
+ };
34
+ var hasSize = (args) => {
35
+ return "size" in args && typeof args.size === "string";
36
+ };
37
+ var hasSizeattach = (args) => {
38
+ return "sizeattach" in args && typeof args.sizeattach === "string";
39
+ };
28
40
  var generatePrintUri = (args) => {
41
+ validateArgs(args);
29
42
  const searchParams = convertArgsToSearchParams(args);
30
43
  return new URL(`brotherwebprint://print?${searchParams.toString()}`);
31
44
  };
45
+ var validateArgs = (args) => {
46
+ const hasFile = hasFilename(args);
47
+ const hasAttach = hasFileattach(args);
48
+ if (!hasFile && !hasAttach) {
49
+ throw new Error("Either 'filename' or 'fileattach' must be provided");
50
+ }
51
+ if (hasFile && hasAttach) {
52
+ throw new Error("Only one of 'filename' or 'fileattach' can be provided, not both");
53
+ }
54
+ const hasSizeParam = hasSize(args);
55
+ const hasSizeAttach = hasSizeattach(args);
56
+ if (!hasSizeParam && !hasSizeAttach) {
57
+ throw new Error("Either 'size' or 'sizeattach' must be provided");
58
+ }
59
+ if (hasSizeParam && hasSizeAttach) {
60
+ throw new Error("Only one of 'size' or 'sizeattach' can be provided, not both");
61
+ }
62
+ };
32
63
  var convertArgsToSearchParams = (args) => {
33
64
  const searchParams = new URLSearchParams();
34
65
  let property;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/uri-generator.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./uri-generator\";\n","import { BrotherArgs } from \"./types\";\n\nexport const generatePrintUri = (args: BrotherArgs): URL => {\n const searchParams = convertArgsToSearchParams(args);\n return new URL(`brotherwebprint://print?${searchParams.toString()}`);\n};\n\nconst convertArgsToSearchParams = (args: BrotherArgs): URLSearchParams => {\n const searchParams = new URLSearchParams();\n\n let property: keyof typeof args;\n for (property in args) {\n const value = convertValueToString(args[property]);\n if (value) {\n searchParams.append(property, value);\n }\n }\n\n return searchParams;\n};\n\nconst convertValueToString = (\n value: BrotherArgs[keyof BrotherArgs]\n): string | null => {\n switch (typeof value) {\n case \"string\":\n return value;\n case \"number\":\n return value.toString();\n case \"boolean\":\n return value ? \"1\" : \"0\";\n case \"undefined\":\n return null;\n default:\n throw new Error(`Unsupported type: ${typeof value}`);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,mBAAmB,CAAC,SAA2B;AAC1D,QAAM,eAAe,0BAA0B,IAAI;AACnD,SAAO,IAAI,IAAI,2BAA2B,aAAa,SAAS,CAAC,EAAE;AACrE;AAEA,IAAM,4BAA4B,CAAC,SAAuC;AACxE,QAAM,eAAe,IAAI,gBAAgB;AAEzC,MAAI;AACJ,OAAK,YAAY,MAAM;AACrB,UAAM,QAAQ,qBAAqB,KAAK,QAAQ,CAAC;AACjD,QAAI,OAAO;AACT,mBAAa,OAAO,UAAU,KAAK;AAAA,IACrC;AAAA,EACF;AAEA,SAAO;AACT;AAEA,IAAM,uBAAuB,CAC3B,UACkB;AAClB,UAAQ,OAAO,OAAO;AAAA,IACpB,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO,MAAM,SAAS;AAAA,IACxB,KAAK;AACH,aAAO,QAAQ,MAAM;AAAA,IACvB,KAAK;AACH,aAAO;AAAA,IACT;AACE,YAAM,IAAI,MAAM,qBAAqB,OAAO,KAAK,EAAE;AAAA,EACvD;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/uri-generator.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./uri-generator\";\n","import { BrotherArgs } from \"./types\";\n\n/**\n * Type guard to check if filename is present\n */\nconst hasFilename = (args: BrotherArgs): args is BrotherArgs & { filename: string } => {\n return 'filename' in args && typeof args.filename === 'string';\n};\n\n/**\n * Type guard to check if fileattach is present\n */\nconst hasFileattach = (args: BrotherArgs): args is BrotherArgs & { fileattach: string } => {\n return 'fileattach' in args && typeof args.fileattach === 'string';\n};\n\n/**\n * Type guard to check if size is present\n */\nconst hasSize = (args: BrotherArgs): args is BrotherArgs & { size: string } => {\n return 'size' in args && typeof args.size === 'string';\n};\n\n/**\n * Type guard to check if sizeattach is present\n */\nconst hasSizeattach = (args: BrotherArgs): args is BrotherArgs & { sizeattach: string } => {\n return 'sizeattach' in args && typeof args.sizeattach === 'string';\n};\n\nexport const generatePrintUri = (args: BrotherArgs): URL => {\n validateArgs(args);\n const searchParams = convertArgsToSearchParams(args);\n return new URL(`brotherwebprint://print?${searchParams.toString()}`);\n};\n\nconst validateArgs: (args: BrotherArgs) => asserts args is BrotherArgs = (args) => {\n // Validate filename/fileattach using type guards\n const hasFile = hasFilename(args);\n const hasAttach = hasFileattach(args);\n \n if (!hasFile && !hasAttach) {\n throw new Error(\"Either 'filename' or 'fileattach' must be provided\");\n }\n if (hasFile && hasAttach) {\n throw new Error(\"Only one of 'filename' or 'fileattach' can be provided, not both\");\n }\n \n // Validate size/sizeattach using type guards\n const hasSizeParam = hasSize(args);\n const hasSizeAttach = hasSizeattach(args);\n \n if (!hasSizeParam && !hasSizeAttach) {\n throw new Error(\"Either 'size' or 'sizeattach' must be provided\");\n }\n if (hasSizeParam && hasSizeAttach) {\n throw new Error(\"Only one of 'size' or 'sizeattach' can be provided, not both\");\n }\n};\n\nconst convertArgsToSearchParams = (args: BrotherArgs): URLSearchParams => {\n const searchParams = new URLSearchParams();\n\n let property: keyof typeof args;\n for (property in args) {\n const value = convertValueToString(args[property]);\n if (value) {\n searchParams.append(property, value);\n }\n }\n\n return searchParams;\n};\n\nconst convertValueToString = (\n value: BrotherArgs[keyof BrotherArgs]\n): string | null => {\n switch (typeof value) {\n case \"string\":\n return value;\n case \"number\":\n return value.toString();\n case \"boolean\":\n return value ? \"1\" : \"0\";\n case \"undefined\":\n return null;\n default:\n throw new Error(`Unsupported type: ${typeof value}`);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAM,cAAc,CAAC,SAAkE;AACrF,SAAO,cAAc,QAAQ,OAAO,KAAK,aAAa;AACxD;AAKA,IAAM,gBAAgB,CAAC,SAAoE;AACzF,SAAO,gBAAgB,QAAQ,OAAO,KAAK,eAAe;AAC5D;AAKA,IAAM,UAAU,CAAC,SAA8D;AAC7E,SAAO,UAAU,QAAQ,OAAO,KAAK,SAAS;AAChD;AAKA,IAAM,gBAAgB,CAAC,SAAoE;AACzF,SAAO,gBAAgB,QAAQ,OAAO,KAAK,eAAe;AAC5D;AAEO,IAAM,mBAAmB,CAAC,SAA2B;AAC1D,eAAa,IAAI;AACjB,QAAM,eAAe,0BAA0B,IAAI;AACnD,SAAO,IAAI,IAAI,2BAA2B,aAAa,SAAS,CAAC,EAAE;AACrE;AAEA,IAAM,eAAmE,CAAC,SAAS;AAEjF,QAAM,UAAU,YAAY,IAAI;AAChC,QAAM,YAAY,cAAc,IAAI;AAEpC,MAAI,CAAC,WAAW,CAAC,WAAW;AAC1B,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACtE;AACA,MAAI,WAAW,WAAW;AACxB,UAAM,IAAI,MAAM,kEAAkE;AAAA,EACpF;AAGA,QAAM,eAAe,QAAQ,IAAI;AACjC,QAAM,gBAAgB,cAAc,IAAI;AAExC,MAAI,CAAC,gBAAgB,CAAC,eAAe;AACnC,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AACA,MAAI,gBAAgB,eAAe;AACjC,UAAM,IAAI,MAAM,8DAA8D;AAAA,EAChF;AACF;AAEA,IAAM,4BAA4B,CAAC,SAAuC;AACxE,QAAM,eAAe,IAAI,gBAAgB;AAEzC,MAAI;AACJ,OAAK,YAAY,MAAM;AACrB,UAAM,QAAQ,qBAAqB,KAAK,QAAQ,CAAC;AACjD,QAAI,OAAO;AACT,mBAAa,OAAO,UAAU,KAAK;AAAA,IACrC;AAAA,EACF;AAEA,SAAO;AACT;AAEA,IAAM,uBAAuB,CAC3B,UACkB;AAClB,UAAQ,OAAO,OAAO;AAAA,IACpB,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO,MAAM,SAAS;AAAA,IACxB,KAAK;AACH,aAAO,QAAQ,MAAM;AAAA,IACvB,KAAK;AACH,aAAO;AAAA,IACT;AACE,YAAM,IAAI,MAAM,qBAAqB,OAAO,KAAK,EAAE;AAAA,EACvD;AACF;","names":[]}
package/dist/index.mjs CHANGED
@@ -1,8 +1,39 @@
1
1
  // src/uri-generator.ts
2
+ var hasFilename = (args) => {
3
+ return "filename" in args && typeof args.filename === "string";
4
+ };
5
+ var hasFileattach = (args) => {
6
+ return "fileattach" in args && typeof args.fileattach === "string";
7
+ };
8
+ var hasSize = (args) => {
9
+ return "size" in args && typeof args.size === "string";
10
+ };
11
+ var hasSizeattach = (args) => {
12
+ return "sizeattach" in args && typeof args.sizeattach === "string";
13
+ };
2
14
  var generatePrintUri = (args) => {
15
+ validateArgs(args);
3
16
  const searchParams = convertArgsToSearchParams(args);
4
17
  return new URL(`brotherwebprint://print?${searchParams.toString()}`);
5
18
  };
19
+ var validateArgs = (args) => {
20
+ const hasFile = hasFilename(args);
21
+ const hasAttach = hasFileattach(args);
22
+ if (!hasFile && !hasAttach) {
23
+ throw new Error("Either 'filename' or 'fileattach' must be provided");
24
+ }
25
+ if (hasFile && hasAttach) {
26
+ throw new Error("Only one of 'filename' or 'fileattach' can be provided, not both");
27
+ }
28
+ const hasSizeParam = hasSize(args);
29
+ const hasSizeAttach = hasSizeattach(args);
30
+ if (!hasSizeParam && !hasSizeAttach) {
31
+ throw new Error("Either 'size' or 'sizeattach' must be provided");
32
+ }
33
+ if (hasSizeParam && hasSizeAttach) {
34
+ throw new Error("Only one of 'size' or 'sizeattach' can be provided, not both");
35
+ }
36
+ };
6
37
  var convertArgsToSearchParams = (args) => {
7
38
  const searchParams = new URLSearchParams();
8
39
  let property;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/uri-generator.ts"],"sourcesContent":["import { BrotherArgs } from \"./types\";\n\nexport const generatePrintUri = (args: BrotherArgs): URL => {\n const searchParams = convertArgsToSearchParams(args);\n return new URL(`brotherwebprint://print?${searchParams.toString()}`);\n};\n\nconst convertArgsToSearchParams = (args: BrotherArgs): URLSearchParams => {\n const searchParams = new URLSearchParams();\n\n let property: keyof typeof args;\n for (property in args) {\n const value = convertValueToString(args[property]);\n if (value) {\n searchParams.append(property, value);\n }\n }\n\n return searchParams;\n};\n\nconst convertValueToString = (\n value: BrotherArgs[keyof BrotherArgs]\n): string | null => {\n switch (typeof value) {\n case \"string\":\n return value;\n case \"number\":\n return value.toString();\n case \"boolean\":\n return value ? \"1\" : \"0\";\n case \"undefined\":\n return null;\n default:\n throw new Error(`Unsupported type: ${typeof value}`);\n }\n};\n"],"mappings":";AAEO,IAAM,mBAAmB,CAAC,SAA2B;AAC1D,QAAM,eAAe,0BAA0B,IAAI;AACnD,SAAO,IAAI,IAAI,2BAA2B,aAAa,SAAS,CAAC,EAAE;AACrE;AAEA,IAAM,4BAA4B,CAAC,SAAuC;AACxE,QAAM,eAAe,IAAI,gBAAgB;AAEzC,MAAI;AACJ,OAAK,YAAY,MAAM;AACrB,UAAM,QAAQ,qBAAqB,KAAK,QAAQ,CAAC;AACjD,QAAI,OAAO;AACT,mBAAa,OAAO,UAAU,KAAK;AAAA,IACrC;AAAA,EACF;AAEA,SAAO;AACT;AAEA,IAAM,uBAAuB,CAC3B,UACkB;AAClB,UAAQ,OAAO,OAAO;AAAA,IACpB,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO,MAAM,SAAS;AAAA,IACxB,KAAK;AACH,aAAO,QAAQ,MAAM;AAAA,IACvB,KAAK;AACH,aAAO;AAAA,IACT;AACE,YAAM,IAAI,MAAM,qBAAqB,OAAO,KAAK,EAAE;AAAA,EACvD;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/uri-generator.ts"],"sourcesContent":["import { BrotherArgs } from \"./types\";\n\n/**\n * Type guard to check if filename is present\n */\nconst hasFilename = (args: BrotherArgs): args is BrotherArgs & { filename: string } => {\n return 'filename' in args && typeof args.filename === 'string';\n};\n\n/**\n * Type guard to check if fileattach is present\n */\nconst hasFileattach = (args: BrotherArgs): args is BrotherArgs & { fileattach: string } => {\n return 'fileattach' in args && typeof args.fileattach === 'string';\n};\n\n/**\n * Type guard to check if size is present\n */\nconst hasSize = (args: BrotherArgs): args is BrotherArgs & { size: string } => {\n return 'size' in args && typeof args.size === 'string';\n};\n\n/**\n * Type guard to check if sizeattach is present\n */\nconst hasSizeattach = (args: BrotherArgs): args is BrotherArgs & { sizeattach: string } => {\n return 'sizeattach' in args && typeof args.sizeattach === 'string';\n};\n\nexport const generatePrintUri = (args: BrotherArgs): URL => {\n validateArgs(args);\n const searchParams = convertArgsToSearchParams(args);\n return new URL(`brotherwebprint://print?${searchParams.toString()}`);\n};\n\nconst validateArgs: (args: BrotherArgs) => asserts args is BrotherArgs = (args) => {\n // Validate filename/fileattach using type guards\n const hasFile = hasFilename(args);\n const hasAttach = hasFileattach(args);\n \n if (!hasFile && !hasAttach) {\n throw new Error(\"Either 'filename' or 'fileattach' must be provided\");\n }\n if (hasFile && hasAttach) {\n throw new Error(\"Only one of 'filename' or 'fileattach' can be provided, not both\");\n }\n \n // Validate size/sizeattach using type guards\n const hasSizeParam = hasSize(args);\n const hasSizeAttach = hasSizeattach(args);\n \n if (!hasSizeParam && !hasSizeAttach) {\n throw new Error(\"Either 'size' or 'sizeattach' must be provided\");\n }\n if (hasSizeParam && hasSizeAttach) {\n throw new Error(\"Only one of 'size' or 'sizeattach' can be provided, not both\");\n }\n};\n\nconst convertArgsToSearchParams = (args: BrotherArgs): URLSearchParams => {\n const searchParams = new URLSearchParams();\n\n let property: keyof typeof args;\n for (property in args) {\n const value = convertValueToString(args[property]);\n if (value) {\n searchParams.append(property, value);\n }\n }\n\n return searchParams;\n};\n\nconst convertValueToString = (\n value: BrotherArgs[keyof BrotherArgs]\n): string | null => {\n switch (typeof value) {\n case \"string\":\n return value;\n case \"number\":\n return value.toString();\n case \"boolean\":\n return value ? \"1\" : \"0\";\n case \"undefined\":\n return null;\n default:\n throw new Error(`Unsupported type: ${typeof value}`);\n }\n};\n"],"mappings":";AAKA,IAAM,cAAc,CAAC,SAAkE;AACrF,SAAO,cAAc,QAAQ,OAAO,KAAK,aAAa;AACxD;AAKA,IAAM,gBAAgB,CAAC,SAAoE;AACzF,SAAO,gBAAgB,QAAQ,OAAO,KAAK,eAAe;AAC5D;AAKA,IAAM,UAAU,CAAC,SAA8D;AAC7E,SAAO,UAAU,QAAQ,OAAO,KAAK,SAAS;AAChD;AAKA,IAAM,gBAAgB,CAAC,SAAoE;AACzF,SAAO,gBAAgB,QAAQ,OAAO,KAAK,eAAe;AAC5D;AAEO,IAAM,mBAAmB,CAAC,SAA2B;AAC1D,eAAa,IAAI;AACjB,QAAM,eAAe,0BAA0B,IAAI;AACnD,SAAO,IAAI,IAAI,2BAA2B,aAAa,SAAS,CAAC,EAAE;AACrE;AAEA,IAAM,eAAmE,CAAC,SAAS;AAEjF,QAAM,UAAU,YAAY,IAAI;AAChC,QAAM,YAAY,cAAc,IAAI;AAEpC,MAAI,CAAC,WAAW,CAAC,WAAW;AAC1B,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACtE;AACA,MAAI,WAAW,WAAW;AACxB,UAAM,IAAI,MAAM,kEAAkE;AAAA,EACpF;AAGA,QAAM,eAAe,QAAQ,IAAI;AACjC,QAAM,gBAAgB,cAAc,IAAI;AAExC,MAAI,CAAC,gBAAgB,CAAC,eAAe;AACnC,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AACA,MAAI,gBAAgB,eAAe;AACjC,UAAM,IAAI,MAAM,8DAA8D;AAAA,EAChF;AACF;AAEA,IAAM,4BAA4B,CAAC,SAAuC;AACxE,QAAM,eAAe,IAAI,gBAAgB;AAEzC,MAAI;AACJ,OAAK,YAAY,MAAM;AACrB,UAAM,QAAQ,qBAAqB,KAAK,QAAQ,CAAC;AACjD,QAAI,OAAO;AACT,mBAAa,OAAO,UAAU,KAAK;AAAA,IACrC;AAAA,EACF;AAEA,SAAO;AACT;AAEA,IAAM,uBAAuB,CAC3B,UACkB;AAClB,UAAQ,OAAO,OAAO;AAAA,IACpB,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO,MAAM,SAAS;AAAA,IACxB,KAAK;AACH,aAAO,QAAQ,MAAM;AAAA,IACvB,KAAK;AACH,aAAO;AAAA,IACT;AACE,YAAM,IAAI,MAAM,qBAAqB,OAAO,KAAK,EAAE;AAAA,EACvD;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brother-smooth-print-uri",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "URI Generator for Brother Smooth Print",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",