{"id":23002669,"url":"https://github.com/treedomtrees/commercetools-where-string-builder","last_synced_at":"2025-08-14T01:31:30.285Z","repository":{"id":65667712,"uuid":"596932163","full_name":"treedomtrees/commercetools-where-string-builder","owner":"treedomtrees","description":"CommerceTools where string builder","archived":false,"fork":false,"pushed_at":"2024-11-06T09:08:56.000Z","size":16,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-29T16:43:50.387Z","etag":null,"topics":["commercetools","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@treedom/commercetools-where-string-builder","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/treedomtrees.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2023-02-03T08:46:57.000Z","updated_at":"2024-11-06T09:17:56.000Z","dependencies_parsed_at":"2023-02-19T06:16:02.363Z","dependency_job_id":null,"html_url":"https://github.com/treedomtrees/commercetools-where-string-builder","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treedomtrees%2Fcommercetools-where-string-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treedomtrees%2Fcommercetools-where-string-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treedomtrees%2Fcommercetools-where-string-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treedomtrees%2Fcommercetools-where-string-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/treedomtrees","download_url":"https://codeload.github.com/treedomtrees/commercetools-where-string-builder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229790986,"owners_count":18124607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["commercetools","typescript"],"created_at":"2024-12-15T07:11:58.384Z","updated_at":"2024-12-15T07:11:59.091Z","avatar_url":"https://github.com/treedomtrees.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @treedom/commercetools-where-string-builder\n\n\u003ca href=\"https://www.treedom.net/it/organization/treedom/event/treedom-open-source?utm_source=github\"\u003e\u003cimg src=\"https://badges.treedom.net/badge/f/treedom-open-source?utm_source=github\" alt=\"plant-a-tree\" border=\"0\" /\u003e\u003c/a\u003e\n\nA simple programmatic builder for CommerceTools `where` [Query Predicates](https://docs.commercetools.com/api/predicates/query)\n\nPerforms stringification and quote escaping for string, boolean and numerical values\n\n__Made with ❤️ at\u0026nbsp;\u0026nbsp;[\u003cimg src=\"https://assets.treedom.net/image/upload/manual_uploads/treedom-logo-contrib_gjrzt6.png\" height=\"24\" alt=\"Treedom\" border=\"0\" align=\"top\" /\u003e](#-join-us-in-making-a-difference-)__, [join us in making a difference](#-join-us-in-making-a-difference-)!\n\n## Usage\n\n```typescript\nimport { Field, Equals, And } from \"@treedom/commercetools-where-string-builder\";\n\nField(\n  \"masterData\",\n  \"current\",\n  \"masterVariant\",\n  And(\n    Equals(\"key\", \"my-variant-key\"),\n    Field(\n      \"attributes\",\n      And(\n        Equals(\"name\", \"my-attribute-key\"),\n        Equals(\"value\", \"my-attribute-value\")\n      )\n    )\n  )\n);\n```\n\nThis snippet builds the following where query string\n\n```\nmasterData(current(masterVariant((key = \"my-variant-key\") and (attributes((name = \"my-attribute-key\") and (value = \"my-attribute-value\"))))))\n```\n\n## Predicates\n\n### Field: (...fields: Array\u0026lt;string\u0026gt;) =\u003e string\n\n```typescript\nField(\"bar\", \"baz\", \"foo\"); // bar(baz(foo)))\n```\n\n### And: (...fields: Array\u003cstring | Array\u003cstring\u003e\u003e) =\u003e string\n\n```typescript\nAnd(\"bar\", \"baz\"); // (bar) and (baz)\n```\n\n### Or: (...fields: Array\u003cstring | Array\u003cstring\u003e\u003e) =\u003e string\n\n```typescript\nOr(\"bar\", \"baz\"); // (bar) or (baz)\n```\n\n### Compare: (field: string, operator: \"=\" | \"!=\" | \"\u003e\" | \"\u003c\" | \"\u003e=\" | \"\u003c=\" | \"\u003c\u003e\", value: number | boolean | string) =\u003e string\n\n```typescript\nCompare(\"bar\", \"\u003c=\", 5); // bar \u003c= 5\n```\n\n### Equals: (field: string, value: number | boolean | string) =\u003e string\n\n```typescript\nEquals(\"bar\", 5); // bar = 5\n```\n\n### NotEquals: (field: string, value: number | boolean | string) =\u003e string\n\n```typescript\nNotEquals(\"bar\", 5); // bar != 5\n```\n\n### GreaterThan: (field: string, value: number | string) =\u003e string\n\n```typescript\nGreaterThan(\"bar\", 5); // bar \u003e 5\n```\n\n### LessThan: (field: string, value: number | string) =\u003e string\n\n```typescript\nLessThan(\"bar\", 5); // bar \u003e 5\n```\n\n### GreaterOrEqualThan: (field: string, value: number | string) =\u003e string\n\n```typescript\nGreaterOrEqualThan(\"bar\", 5); // bar \u003e= 5\n```\n\n### LessOrEqualThan: (field: string, value: number | string) =\u003e string\n\n```typescript\nLessOrEqualThan(\"bar\", 5); // bar \u003c= 5\n```\n\n### Contains: (field: string, kind: \"any\" | \"all\", values: Array\u003cnumber | boolean | string\u003e) =\u003e string\n\n```typescript\nContains(\"bar\", \"any\", [\"str\", 123, true]); // bar contains any (\"str\", 123, true)\n```\n\n### ContainsAll: (field: string, values: Array\u003cnumber | boolean | string\u003e) =\u003e string\n\n```typescript\nContainsAll(\"bar\", [\"str\", 123, true]); // bar contains all (\"str\", 123, true)\n```\n\n### ContainsAny: (field: string, values: Array\u003cnumber | boolean | string\u003e) =\u003e string\n\n```typescript\nContainsAny(\"bar\", [\"str\", 123, true]); // bar contains any (\"str\", 123, true)\n```\n\n### In: (field: string, values: Array\u003cnumber | boolean | string\u003e) =\u003e string\n\n```typescript\nIn(\"bar\", [\"str\", 123, true]); // bar in (\"str\", 123, true)\n```\n\n### NotIn: (field: string, values: Array\u003cnumber | boolean | string\u003e) =\u003e string\n\n```typescript\nNotIn(\"bar\", [\"str\", 123, true]); // bar not in (\"str\", 123, true)\n```\n\n### IsDefined: (field: string) =\u003e string\n\n```typescript\nIsDefined(\"bar\"); // bar is defined\n```\n\n### IsNotDefined: (field: string) =\u003e string\n\n```typescript\nIsNotDefined(\"bar\"); // bar is defined\n```\n\n### HasChanged: (field: string) =\u003e string\n\n```typescript\nHasChanged(\"bar\"); // bar has changed\n```\n\n### HasNotChanged: (field: string) =\u003e string\n\n```typescript\nHasNotChanged(\"bar\"); // bar has not changed\n```\n\n### WithinCircle: (field: string, latitude: number, longitude: number, radius: number) =\u003e string\n\n```typescript\nWithinCircle(\"bar\", 75.2345, 12.2345, 100); // bar within circle(75.2345, 12.2345, 100)\n```\n\n## 🌳 Join Us in Making a Difference! 🌳\n\nWe invite all developers who use Treedom's open-source code to support our mission of sustainability by planting a tree with us. By contributing to reforestation efforts, you help create a healthier planet and give back to the environment. Visit our [Treedom Open Source Forest](https://www.treedom.net/en/organization/treedom/event/treedom-open-source) to plant your tree today and join our community of eco-conscious developers.\n\nAdditionally, you can integrate the Treedom GitHub badge into your repository to showcase the number of trees in your Treedom forest and encourage others to plant new ones. Check out our [integration guide](https://github.com/treedomtrees/.github/blob/main/TREEDOM_BADGE.md) to get started.\n\nTogether, we can make a lasting impact! 🌍💚\n\n## Contributing\n\nContributions are welcome! Please read the contributing guidelines before submitting a pull request.\n\n## License\n\nThis project is licensed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreedomtrees%2Fcommercetools-where-string-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftreedomtrees%2Fcommercetools-where-string-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreedomtrees%2Fcommercetools-where-string-builder/lists"}